Page 1 of 1

Timer0 Problem

Posted: Mon Feb 21, 2011 2:19 pm
by wayne millard
Hi Matrix Team,

Can you please tell me what am i doing wrong my project works but the time that it generates is not as accurate
as it should be. i have a 10us interrupt running. it seems that the 10us is not quite 10us why and what can i do to fix it. is it the counter i have in the interrrupt?

Thanks,
Wayne m :cry:

Re: Timer0 Problem

Posted: Mon Feb 21, 2011 11:32 pm
by medelec35
I have tested the 10us in a simulator with OSC set at 40MHz. Interrupt was accessed every 10.20uS not exactly 10uS, but not far off.
If you have a scope, you could always test interrupt access time by the following method:
Test timer0.jpg
Test timer0.jpg (32.02 KiB) Viewed 2445 times
Just measure time or frequency at port C3 of target device
Are you using the 10MHz xtal you mentioned in a different post? If not what crystal are you using?
Do you have to use a very sort time like 10uS and count up to 5000, or can you use a longer time period e.g 100uS and count up to 500 for your shortest delay?

Re: Timer0 Problem

Posted: Tue Feb 22, 2011 1:36 pm
by wayne millard
Hi medelec35,

So there is about a 2% error in the timing. so i calculate interrupt counts for required time then subtract 2% of the counts i still dont get the accuracy over all the time spane.

Help
Wayne