Hi,
I am doing some time specific processing in my PIC16F690 and I keep track of it via timer 1. However I am suspicious that the timer is not being reset when I ask it to. Can someone check that what I am doing is correct for resetting Timer 1? Please excuse the rough syntax.
Setup timer - Do this just once at the start of the program
TMR1IE.PIE1 = 1 Enable timer 1 interrupt
INTCON = %11000000 Set the PEIE and GIE bits
PIR1.TMR1IF = 0 Clear the interrupt flag
Reset portion - this gets recalled whenever I want to reset the timer
T1CON = %00110000 Turn on 1:8 prescalar - turn timer off
TMR1H = $00 Set high register to 0
TMR1L = $00 Set low register to 0
PIR1.TMR1IF = 0 Clear any interrupt flags
T1CON.TMR1ON = 1 Finally turn the timer on
Interrupt option - this shouldn't get called but have it here to handle any errors
PIR1.TMR1IF = 0 Clear the interrupt
--- I set another non timer related flag here as well -----
Whenever I check what the timer values are I do:
TMR1H * 256 + TMR1L
I am not 100% sure but I think my timer is not starting at 0 again when I do a reset. Can anyone see a problem?
Many thanks,
Craig
I am doing some time specific processing in my PIC16F690 and I keep track of it via timer 1. However I am suspicious that the timer is not being reset when I ask it to. Can someone check that what I am doing is correct for resetting Timer 1? Please excuse the rough syntax.
Setup timer - Do this just once at the start of the program
TMR1IE.PIE1 = 1 Enable timer 1 interrupt
INTCON = %11000000 Set the PEIE and GIE bits
PIR1.TMR1IF = 0 Clear the interrupt flag
Reset portion - this gets recalled whenever I want to reset the timer
T1CON = %00110000 Turn on 1:8 prescalar - turn timer off
TMR1H = $00 Set high register to 0
TMR1L = $00 Set low register to 0
PIR1.TMR1IF = 0 Clear any interrupt flags
T1CON.TMR1ON = 1 Finally turn the timer on
Interrupt option - this shouldn't get called but have it here to handle any errors
PIR1.TMR1IF = 0 Clear the interrupt
--- I set another non timer related flag here as well -----
Whenever I check what the timer values are I do:
TMR1H * 256 + TMR1L
I am not 100% sure but I think my timer is not starting at 0 again when I do a reset. Can anyone see a problem?
Many thanks,
Craig
Last edited: