I have been programming PIC18F8720’s for the last few days. And things have been going OK. But I have been working with some TIMER code, and I did some calculations, and what I found was that the timer was being called a heap more than it should have been. In the example code it was being called 240 times more often. 240 times.
PR4 = 195
IPR3.3 = 1
PIR3.3 = 0
T4CON = %01111111
And then in my main loop I compared PIR3.3 and called the timer handler if it was HIGH. This code was fairly simple
if PIR3.3 = 1 then GOSUB TIMER_LOOP ' Timer has elapsed. Therefore Do It
But the code was running a heap more than it should have. I worked out I needed to INIT the timer every time through the TIMER_LOOP. The code below shows the GOSUB. It now works.
TimerCount = TimerCount + 1
if timercount > 10 then
LED = 1 - LED
timercount = 0
LCDOUT $FE, $C0, "Now :", DEC LED