I don't find any specific answer to this question : Is it possible to have delay (for a specific protocol maybe) less than 1mS (say 335 uS) or I have to use ASM code ? Thank you for your time !
I don't find any specific answer to this question : Is it possible to have delay (for a specific protocol maybe) less than 1mS (say 335 uS) or I have to use ASM code ? Thank you for your time !
Try the PAUSEUS command.
Here are the details as listed in the manual - http://www.melabs.com/resources/pbpmanual/ - (which should of been the first place to look)
PAUSEUS
PAUSEUS Period
Pause the program for Period microseconds. Period is 16-bits, so delays can be up to 65,535 microseconds. Unlike the other delay functions (NAP and SLEEP), PAUSEUS doesn't put the microcontroller into low power mode. Thus, PAUSEUS consumes more power but is also much more accurate. It has the same accuracy as the system clock.
Because PAUSEUS takes a minimum number of cycles to operate, depending on the frequency of the oscillator, delays of less than a minimum number of microseconds are not possible using PAUSEUS. To obtain shorter delays, use an assembly language routine in an ASM..ENDASM construct.
OSC Minimum delay
3 (3.58) 20us
4 24us
8 12us
10 8us
12 7us
16 5us
20 3us
25* 2us
32* 2us
33* 2us
40** 2us
* PIC17Cxxx and PIC18Cxxx only.
** PIC18Cxxx only.
PAUSEUS assumes an oscillator frequency of 4MHz. If an oscillator other that 4MHz is used, PBP must be told using a DEFINE OSC command. See the section on speed for more information.
PAUSEUS 1000 ' Delay for 1 millisecond
Originally Posted by malc-c
That's amazing isn't it? You find the wierdest information in the oddest places.Especially if the information (the PBP book) came with the program package (bought directly from MeLabs).
JDG
Come on Skimask![]()
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Can someone please explain me how to use assembly to make shorter delay than pauseus can make ?
Hi,
The shortest possible delay is achieved by using the assembler command NOP (short for No OPeration):
The NOP instruction takes 1uS at 4Mhz and 250nS at 20Mhz etc. If you want longer delay add more NOP instructions or build a loop, but then it's probably easier to use PauseUs anyway.Code:@NOP 'Delay for OSC/4
/Henrik Olsson.
Bookmarks