I should mention one thing about using the tick timer. When I origonaly wrote this,
[code:1:19ca353af3]
'=====[ Setup Timer1 for Tick isr ]============================================
' Timer1 is used for Tick counter at 100Hz
Config Timer1 = Timer , Prescale = 1024 , Compare A = Disconnect , Clear Timer = 1
' crytal / prescale / x Hz = Compare1a val needed
' 18432000 / 1024 / 100(Hz) = 180
' 14745600 / 1024 / 100(Hz) = 144
' 7372800 / 1024 / 100(Hz) = 72
Compare1a = 144
On Compare1a T1_tickcounter_isr
Enable Timer1
Enable Compare1a
[/code:1:19ca353af3]
I forgot to subtract 1 from the calculated value as per Atmel documentation. So the line:
Compare1a = 144
should be:
Compare1a = 144 - 1
Let me know if this makes the timer more accurate for you...
-Glen
↧