25.4.1.2 Synchronous Counter Initialization Steps
The following steps must be performed to configure the timer for Synchronous Counter mode:
- Clear the TON control bit (TxCON[15] = 0) to disable the timer.
- Clear the TCS control bit (TxCON[1] = 0) to select the internal system clock source.
- Select the desired timer input clock prescale.
- Load/clear the Timer register, TMRx.
- Load the Timer Period register, PRx, with the desired 32-bit match value.
- If interrupts are used:
- Clear the TxIF Interrupt Flag bit in the IFSx register.
- Configure the Interrupt Priority Levels in the IPCx register.
- Set the TxIE Interrupt Enable bit in the IECx register.
- Set the TON control bit (T1CON[15] = 1) to enable the timer.
Synchronous Counter Example Code
T1CON = 0x0; // Stop timer and clear control register,
// set prescaler at 1:1, internal clock source
TMR1 = 0x0; // Clear timer register
PR1 = 0xFFFFFFFF; // Load period register
T1CONbits.ON = 1; // Start timer