William Roth - 2015-03-05

Using A PIC, the ClearTimer command not only clears the timer but also STOPS the timer. I think this should be noted in the HELP File.

However, after a ClearTimer command is called, the timer variable is not cleared to 0 but rather to 1.

The clear to 1 anomaly can be fixed by modifying the timer.h subs to set TMR1H and TM1RL bits to zero AFTER the sInitTimer call.

Tested with PIC16F690., AVR not Tested

Examples:

; From Timer.H
; This clears the TIMER1 variable to 1

 #ifdef Var(T1CON)
    If TMRNumber = 1 then
        TMR1H = 0
        TMR1L = 0               
        SInitTimer1
    End If
 #endif

; =======================================

; Suggested Change to Timer.H
; This clears the Timer1 Variable to 0

 #ifdef Var(T1CON)
    If TMRNumber = 1 then
        SInitTimer1
        TMR1H = 0
        TMR1L = 0
    End If
 #endif

In My case I simply want to clear timer1 on-the-fly so ClearTimer does not work for that since it stop the timer. To clear the timer without stopping it I must do the following.

TMR1H = 0: TMR1L = 0 

.
.
William

 

Last edit: William Roth 2015-03-05