I'm trying to use TMR0 for one second periods, but can't seem to get it. I'm using a PIC16F887 with a 4MHz clock. From what I understand you take (((4MHz / 4) / 256) / prescaler) which will give you the total overflows per second. I know that it won't be an exact second every time it advances, but it should correct itself over time. I'm using a prescaler of two and this is what I have so far:
(1MHz / 256) / 2 = 1953.125
1953.125 * 8 = 15625
Code:
While (INTCON.2 == 0) : WEND
INTCON.2 = 0
Time = Time + 8
if (Time > 15625) Then
Time = Time - 15625
gosub Second
endif
Is there something wrong with what I did? I can't seem to get the clock to be very accurate.
Bookmarks