programmable delay of around 1us using pic18f8722 and 20 Mhz crystal.....

Status
Not open for further replies.

jit_singh_tara

Full Member level 6
Joined
Dec 22, 2006
Messages
325
Helped
9
Reputation
18
Reaction score
4
Trophy points
1,298
Location
Delhi , India
Activity points
4,293
hello friends ,
i was making a customised function for generation of delay say : delay_custom_us(unsigned int).

Now the problem is i am not able to get 1us delay and delays in its multiples.The moment i use for or while loop they consume instruction cycles and hence additional time .Please suggest what to do and how. I want precise delay of 1us ,10us , so that whatever parameter i give in function i should get that delay.
please suggest how to proceed.
 
Last edited:

you will not be able to get reliable delays from a subroutine unless you are willing to look at the disassembly.

the most efficient (from a programming point of view) and the least efficient (from a code size point of view) way to get reliable but short delays is to use NOP().

for longer and reliable delays (>100us) you have to rely on timers.
 
do i have to use a for loop with a nop(); the for loop itself consumes instruction cycles, how will i get precise delay........?
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…