delay for 10 microseconds

Status
Not open for further replies.

curious7

Newbie level 2
Joined
Jan 23, 2013
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,297
I want to generate 10 us delay.
so how to create such delay in pic 18f.
the processor speed is 48mhz
crystal is 12mhz


tell me the genral idea of timer n counter to develop this.
 

better way you can use nop commands if ur controller support. that is no operation. or better way use in-line assemly use 10 instruction's. if u want accurate u should consider the the time required to jump to that function address.
 

if it's matter of delay then why he should waste one timer from limited timers.
rather than use any function for delay for use of delay.
 

delay of 10µS to do in ASM or C langage ?

FOsc 48MHz -> /4 => 12MHz 1 cycle = 1/12=0.0833µS for a NOP instruction
ASM
goto $+1 takes 2 cycles .. 1µS => 1/0.0833=> 12 10µS=> 120 cycles goto takes 2 cycles
goto $+1
goto $+1
.....
....
60 times goto $+1


In C langage

use
_asm goto $+1
.. maybe less than 60 times...

or

use a timer 8 bits
Load it before with 256-120=136
with prescaler=1
and test the TMRx.IF over flag
in a loop.
Be carreful of duration of C instruction .. so final value to load into timer will be more than 136 to get exactly 10µS
 

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…