Page 1 of 1

delay

Posted: Tue Mar 08, 2011 2:35 pm
by wayne millard
Hi Team

How can i generate a delay in nano seconds my clock is 40Mhz and using a 18f4620

Thanks
Wayne

Re: delay

Posted: Tue Mar 08, 2011 3:35 pm
by saschech@gmx.de
Hello wayne

I think you can not do these:
http://www.sprut.de/electronic/pic/8bit ... ht8720.htm

at 20mhz =
Almost all commands of a PIC take a cycle, where a cycle is 4 external PIC bars. A 20-MHz PIC creates so 5 million instructions per second, as in a second 5 million cycles or 20 million external clocks. A cycle is here 0,2 microsecond (0.2 µs) long.
at 40mhz = 0,2ys : 2 = 0,1ys = 100ns........

1 Pikosekunde = 0,000 000 000 001 Sekunden = 10-12 Sekunden
1 Nanosekunde = 1000 Pikosekunden = 0,000 000 001 Sekunden = 10-9 Sekunden
1 Mikrosekunde = 1000 Nanosekunden = 0,000 001 Sekunden = 10-6 Sekunden
1 Millisekunde = 1000 Mikrosekunden = 0,001 Sekunden = 10-3 Sekunden
1 Sekunde = 1000 Millisekunden

Regards Wolfgang

Re: delay

Posted: Wed Mar 09, 2011 4:02 pm
by Jan Lichtenbelt
Dear Wayne,

As far as I know, the minimum delay is one NOP (no-operation program step). You can put that in a C-macro as:
{
nop
}
The delay depend on the crystal frequency divided by a factor 4. Thus with a 40 Mhz crystal the delay will be 10 Mhz or 100 nsec. This is the minimum delay which is possible.

Regrads

Jan Lichtenbelt