Thanks got the timer working now but have one more question.
In the above code i stop the timer then work out any TMR1 overun and add it to my timer reload value.Code:T1CON.0 = 0 'Stops Timer TMR1RunOn.Highbyte = TMR1H 'Load the Run-On (Over-Run) value (if any) TMR1RunOn.Lowbyte = TMR1L 'Load the Run-On (Over-Run) value (if any) TMR1RunOn = PreLoad + TMR1RunOn 'Calculate new Preload setting to include any timer overrun TMR1H = TMR1RunOn.HighByte 'Load the timer with new value TMR1L = TMR1RunOn.LowByte 'Load the timer with new value PIR1.0 = 0 'Clear TMR1 int flag T1CON.0 = 1 'Starts Timer
But how do i compensate for the instructions above which clearly take some time to execute?
I must need to add a few more timer ticks to my reload value, but how many? My clock is running at 8mhz.
Bookmarks