View previous topic :: View next topic |
Author |
Message |
mcisabel
Joined: 28 Jul 2005 Posts: 3
|
About timer0 |
Posted: Thu Aug 11, 2005 6:38 am |
|
|
Hi, I`m using a PIC18F452. Can somebody give me some code to make timer0 interrupt every 10 us? |
|
|
MikeValencia
Joined: 04 Aug 2004 Posts: 238 Location: Chicago
|
|
Posted: Thu Aug 11, 2005 9:48 am |
|
|
Do you want 10 microseconds or 10 milliseconds?
At 10 us, you'd be interrupting ALL the time, and won't have any time to do stuff outside the ISR!
For example, at 4MHz, each instruction would take 1uS to fulfill, and isr context saving overhead alone is a good 20+ instructions.
If you really want a solid 10uS delay, then you'd have to turn off interrupts, and do 10 Noops (@4Mhz Fosc), or call delay_us(10); or delay_cycles(10); |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Thu Aug 11, 2005 10:54 am |
|
|
You also don't specify the frequency of the PIC which is important. |
|
|
|