25.4.2.2 Synchronous External Counter Initialization Steps

The following steps must be performed to configure the timer for Synchronous Counter mode:

  1. Clear the TON Control bit (TxCON[15] = 0) to disable the timer.
  2. Set the TCS Control bit (TxCON[1] = 1) to enable the TxCK pin clock selection.
  3. Set the TSYNC Control bit (TxCON[2] = 1) to enable TxCK pin clock synchronization.
  4. Select the desired timer input clock prescale using TCKPS[1:0] bits in TxCON register.
  5. Load/clear the Timer register, TMRx.
  6. Load the Timer Period register, PRx, with the desired 32-bit match value.
  7. If interrupts are used:
    1. Clear the TxIF Interrupt Flag bit in the IFSx register.
    2. Configure the Interrupt Priority Levels in the IPCx register.
    3. Set the TxIE Interrupt Enable bit in the IECx register.
  8. Set the ON Control bit (TxCON[15] = 1) to enable the timer.

Synchronous External Counter Example Code

T1CON = 0x0;			   // Stop timer and clear control register
T1CON = 0x00000106;			     // Set prescaler at 1:1, external clock source
TMR1 = 0x0;				      // Clear timer register
PR1 = 0xFFFFFFFF;			       // Load period register
T1CONbits.ON = 1;			      // Start timer