Searching \ for '[PIC]: NOP Delay' in subject line. ()
Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/time.htm?key=delay
Search entire site for: 'NOP Delay'.

Exact match. Not showing close matches.
'[PIC]: NOP Delay'
2002\07\19@182148 by

Hi 2 All

A friend (really new to pics) ask me about the NOP delay
He look at some samples at piclist archive and found that in one sample nop
gives 0.122msec
he's question is: what cause the delay time?

Regards

Tal Bejerano
AMC - ISRAEL

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email listservmitvma.mit.edu with SET PICList DIGEST in the body

Hi!

NOP instruction takes 1 instruction cycle=4 processor clock cycles. That
gives that one clock cycle takes  0,000122s/4=0,0000305s.
frequency of clock =1 / time of one cycle
=1/0,0000305s=32786,885245901639344262295081967Hz. That was based on
32,786kHz clock(or cristal).

Regards, Samo

{Original Message removed}
The length of the NOP is the same as the length of an instruction (it
actually is an instruction that does nothing), which is one clock cycle, so
it depends on the speed of the oscillator timing the pic. The instruction
cycle time can be calculated using the formula:

instruction cycle = oscillator period * 4

Where the oscillator period is the reciprocal of the frequency or:

period = 1 / oscillator frequency (measured in Hz)

A delay can be made by a loop that loops a certain number of times. Also you
can use
GOTO \$ +1 as a delay. It is twice as long as a NOP because GOTOs take two
instruction cycles to execute. All it means is go to the next instruction.
Hope this helped.

{Original Message removed}
> A friend (really new to pics) ask me about the NOP delay
> He look at some samples at piclist archive and found that
> in one sample nop gives 0.122msec
> he's question is: what cause the delay time?

Using a 32.768kHz crystal, which has an instruction time of

1000000 / (32768 / 4) = 122us

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email listservmitvma.mit.edu with SET PICList DIGEST in the body

So if I understand correctly the calculation is like that
say I am using 32,768Khz crystal
1 / 32768 = 0.0000305
0.0000305 * 4 = 0.000122sec

and if I use 4Mhz crystal
1 / 4,000,000 = 0.00000025 * 4 = 0.000001sec

am I right?

Regards

Tal Bejerano
AMC - ISRAEL

{Original Message removed}
You got it!

-----Original Message-----
From: pic microcontroller discussion list [PICLISTMITVMA.MIT.EDU]On
Behalf Of Tal Bejerano - AMC
Sent: Friday, July 19, 2002 7:27 PM
To: PICLISTMITVMA.MIT.EDU
Subject: Re: [PIC]: NOP Delay

So if I understand correctly the calculation is like that
say I am using 32,768Khz crystal
1 / 32768 = 0.0000305
0.0000305 * 4 = 0.000122sec

and if I use 4Mhz crystal
1 / 4,000,000 = 0.00000025 * 4 = 0.000001sec

am I right?

Regards

Tal Bejerano
AMC - ISRAEL

-----Original Message-----
From: pic microcontroller discussion list
[PICLISTMITVMA.MIT.EDU]On Behalf Of Jinx
Sent: Saturday, July 20, 2002 1:09 AM
To: PICLISTMITVMA.MIT.EDU
Subject: Re: [PIC]: NOP Delay

> A friend (really new to pics) ask me about the NOP delay
> He look at some samples at piclist archive and found that
> in one sample nop gives 0.122msec
> he's question is: what cause the delay time?

Using a 32.768kHz crystal, which has an instruction time of

1000000 / (32768 / 4) = 122us

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email listservmitvma.mit.edu with SET PICList DIGEST in the body

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email listservmitvma.mit.edu with SET PICList DIGEST in the body

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email listservmitvma.mit.edu with SET PICList DIGEST in the body

Tal Bejerano - AMC <PICLISTmitvma.mit.edu> wrote:

> A friend (really new to pics) ask me about the NOP delay He look at
> some samples at piclist archive and found that in one sample nop
> gives 0.122msec he's question is: what cause the delay time?

Tal:

A PIC's program execution speed is dependent on the frequency of its
CLKIN signal; the faster that signal is, the faster the PIC executes
its programs.  Most PICs can be operated with a user-selected CLKIN
frequency from 0 to 20MHz; some commonly-used frequencies are 32768
Hz, 4 MHz, and 20 MHz.

A NOP instruction always takes one instruction cycle.  One
instruction cycle is always equal to 4 CLKIN periods.  The length of
a CLKIN period, however, can vary from 50 nanoseconds all the way up
to infinity.

If a PIC is operated with a 32768 Hz CLKIN frequency, one CLKIN
period is 0.0305 milliseconds.  Four of those CLKIN periods is 0.122
milliseconds, which is what your friend saw.  Clearly, the code he
was viewing was intended to be run on a PIC with a 32768 Hz CLKIN
frequency.

If the same NOP instruction were executed on a PIC running at 4 MHz,
it would take one microsecond; if it were executed on a PIC running
at 20 MKHz, it would take 200 nanoseconds.

-Andy

=== Andrew Warren -- aiwcypress.com
=== Principal Design Engineer
=== Cypress Semiconductor Corporation
===
=== Opinions expressed above do not
=== necessarily represent those of
=== Cypress Semiconductor Corporation

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email listservmitvma.mit.edu with SET PICList DIGEST in the body

At 01:16 AM 7/20/02 +0200, Tal Bejerano - AMC wrote:
>Hi 2 All
>
>A friend (really new to pics) ask me about the NOP delay
>He look at some samples at piclist archive and found that in one sample nop
>gives 0.122msec
>he's question is: what cause the delay time?

A NOP consumes 1 cycle.  1 cycle is defined as Fosc/4.  In other words, a
PIC running at 4 MHz will have a NOP delay time of 1 us.

dwayne

--
Dwayne Reid   <dwaynerplanet.eon.net>
Trinity Electronics Systems Ltd    Edmonton, AB, CANADA
(780) 489-3199 voice          (780) 487-6397 fax

Celebrating 18 years of Engineering Innovation (1984 - 2002)
.-.   .-.   .-.   .-.   .-.   .-.   .-.   .-.   .-.   .-
`-'   `-'   `-'   `-'   `-'   `-'   `-'   `-'   `-'
Do NOT send unsolicited commercial email to this email address.
This message neither grants consent to receive unsolicited
commercial email nor is intended to solicit commercial email.

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email listservmitvma.mit.edu with SET PICList DIGEST in the body

More... (looser matching)
- Last day of these posts
- In 2002 , 2003 only
- Today
- New search...