I am trying to use TMR1 to count TMR0 overflows. To do this I am using TMR1 with gate enabled, and using TMR0 overflow as the gate source.
Using MPLAB SIM, I can see that TMR0 is counting and overflowing. The TMROIF bit in INTCON is being set correctly.
TMR1 counts correctly without the gate enabled, and stops when I enable the gate control - so far so good.
However, TMR0 overflowing does not seem to be triggering the gate. The T1GVAL bit of T1GCON is never set.
I am running TMR1 at Fosc and I have the gate running not in toggle mode or single pulse mode...
TMR0 is running at instruction clock / 256, although I presume that this doesn't matter...
Here are my config bits:
__CONFIG _CONFIG1, _FOSC_INTOSC & _WDTE_OFF & _PWRTE_OFF & _MCLRE_ON & _CP_OFF & _CPD_OFF & _BOREN_OFF & _CLKOUTEN_OFF & _IESO_OFF & _FCMEN_OFF</code>
__CONFIG _CONFIG2, _WRT_OFF & _PLLEN_OFF & _STVREN_OFF & _BORV_19 & _LVP_OFF
and here are the relevant lines where I configure TMR1
banksel T1CON
movlw b'01000001' ; source = Fosc, prescale 1:1, LP osc - no, Timer on
movwf T1CON
banksel T1GCON
movlw b'11000001' ; gate enabled, active high, toggle no, pulse mode no, source TMR0
movwf T1GCON