View previous topic :: View next topic |
Author |
Message |
jujoab
Joined: 05 Aug 2017 Posts: 41 Location: brazil
|
Timer0 interrupt every 64 counts |
Posted: Sun Oct 29, 2017 12:04 am |
|
|
I need to have a Timer0 interrupt every 64 counts or (with a clock of 4 MHz) every 64 Us.
Do I need to initialize the timer low every interrupt to a value of 255 - 64 = 191 ???
Is that the most practical way????
Thanks a lot
jujoab |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19539
|
|
Posted: Sun Oct 29, 2017 2:16 am |
|
|
You are going to have problems.
64uSec is only 64 instructions at your clock. It typically takes up to about 50 instructions just to get into and out of an interrupt.....
You need to be working with a faster processor to do anything practical at such a short interval.
It is always easier and better to use an interrupt that doesn't need you to set offsets like this. several instructions will have already been executed by the time you get into the handler routine.
If instead you went for 4* the CPU clock, then your timer will wrap with you having to do nothing, and you have some time left to actually do something in the routine.... |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Sun Oct 29, 2017 5:07 am |
|
|
Just a comment.
How accurate does the 64us need to be ?
If it needs to be 'bang on' and repeatable, then you'll need to use an external crystal and caps. The internal oscillator, while 'free' and OK for small NON time dependent projects isn't accurate enough for time specific projects. The 4 MHz is a 'nominal' value and does change based on temperature. Even between PICs you'll see a slight difference in speed.
Just something to be aware of.
Jay |
|
|
jujoab
Joined: 05 Aug 2017 Posts: 41 Location: brazil
|
thanks to all |
Posted: Mon Oct 30, 2017 2:21 pm |
|
|
Thanks to all for the valuable information.
I am trying another way, using PWM to generate the tick.
Thanks again
jujoba |
|
|
|