PIC18 16-bit Timer0

Thread Starter


Joined Apr 5, 2010
I am trying to make a 16 bit timer0 interrupt with a delay of 500 msec. My clock is operating at 48 MHz. I will prescale at 1:128. I set up my timer0 first before I load my starting values into the TMR0.

movlw 0x06
movwf T0CON

65536 - .5*48*10^6/(4*128)

I calculated my starting value to be 0x48E3. I need to write my high byte first, and then write the low byte.

movlw 0x48
movwf TMR0H
movlw 0xE3
movwf TMR0L

I enable my timer and set my interrupts:
bsf T0CON,TMR0ON ; enabled timer0

banksel INTCON;
bsf INTCON, TMR0IE ;set timer interrupt

The problem is, my interrupt is not working. When I look at the TMR0H and TMR0L in the watch window, I can see the TMR0L incrementing, but when it overflows, the TMR0H does not increment. (I am reading the TMR0L first, then reading the TMR0H.)

I appreciate any insight into why this interrupt setup is not working, and why the TMR0H is not incrementing.


Thread Starter


Joined Apr 5, 2010
The reason I couldn't see the TMR0H incrementing was that I wasn't properly reading the TMR0L value. I polled for the T0IF and found that it was set when the 16 bit timer overflowed. However, the interrupt is still not working.