SetTimer:
T1CON.0=0 ' Stop the Clock
TMR1RunOn.Highbyte=TMR1H ' Load the Run-On (Over-Run) value (if any)
TMR1RunOn.Lowbyte=TMR1L
TMR1RunOn=TMR1Preset+TMR1RunOn ' Calculate the New (adjusted) value for TMR1
If TMR1CalAR=0 then ' Calibration ADVANCE (add) or RETARD (subtract)
TMR1RunOn=TMR1RunOn+TMR1Cal
else
TMR1RunOn=TMR1RunOn-TMR1Cal
endif
TMR1H=TMR1RunOn.Highbyte ' Save new values to TMR1
TMR1L=TMR1RunOn.Lowbyte
T1CON.0=1 ' Restart the Clock
PIR1.0=0 ' Reset TMR1's Interupt Flag
Return
Ok, code killing aside.... forgive my noobness.
If I strip out the calibration aspect as I dont think i need it. (1sec/60hz = 1 pulse every 16.667ms) should be enough time.....
SetTimer:
T1CON.0=0 ' Stop the Clock
TMR1.Highbyte=TMR1H ' Load the high timer start point
TMR1.Lowbyte=TMR1L ' Load the low timer start point
TMR1.Highbyte= $AB ' Save new values to TMR1 (65535 - 21600 = 43935 = AB9F)
TMR1.Lowbyte= $9F
T1CON.0=1 ' Restart the Clock
PIR1.0=0 ' Reset TMR1's Interupt Flag
Return
This should reset the timer everytime with 43935 as a starting point, leaving 21600 pulses until a rollover and the interupt flag is set, upon which the program needs to increment a counter by 1, store the result in eeprom and reset the counter to start again. Oh, and increment the display aswell ;-)




Bookmarks