8-bit PIC® MCU Timer2 Interrupt

Last modified by Microchip on 2023/11/09 09:03

Timer2 can generate an interrupt when the TMR2 and PR2 registers match. That match signal can also feed a postscaler to delay the number of matches required to initiate a Timer2 interrupt. The output of the postscaler sets the Timer2 Interrupt Flag bit (TMR2IF) of the Peripheral Interrupt (PIR1) register. The interrupt is enabled by setting the TMR2 Match Interrupt Enable bit (TMR2IE) of the Peripheral Interrupt Enable (PIE1) register.

Timer2 clock postscaler

TOUTPS3:TOUTPS0

0000 = 1:1

0001 = 1:2

0010 = 1:3

1111 = 1:16

The postscaler has a range of 1:1 through 1:16 and is selected by the Timer Output Postscaler Select bits (T2OUTPS) of the Timer2 Control register (T2CON).