Re: timer/counter questions
Robert, without an ISR the timing is not very precise but you can try the following:
'-------------- set the registers -------------------------------
T1CON = %00111101 ' set timer1 as timer with prescaler 1:8
PIE1.0 = 1 ' enable interrupt on overflow
PIR1.0 = 0 ' clear interrupt flag
TMR1L = 220 ' 100 millisecs overflow
TMR1H = 11 ' 100 millisecs overflow
W_Count VAR WORD
'-----------------------------------------------------------------
Poll in the approriate point, somewhere in your program:
If PIR1.0 = 1 THEN
T1CON.0 = 0
PIR1.0 = 0
TMR1L = 220
TMR1H = 11
W_Count = W_Count +1
T1CON.0 = 1
endif
IF W_Count = 300 then
W_Count = 0
Do your job since 30 seconds have been elapsed..
endif
You can trim the 300 to better achieve the 30 seconds delay. (300 x 100 millisecs = 30 seconds)
Cheers
Al.
All progress began with an idea
Bookmarks