23.4.5.3 Asynchronous External Clock Counter Initialization Steps

The following steps must be performed to configure the timer for 32-bit Asynchronous Counter mode:

  1. Clear the ON bit (TxCON[15] = 0) to disable the timer.
  2. Set the TCS bit (TxCON[1] = 1) to enable external clock selection from TxCK pin.
  3. Clear the TSYNC Control bit (TxCON[2] = 0) to disable clock synchronization.
  4. Select the desired prescaler.
  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 IFS register.
    2. Configure the interrupt priority levels in the IPC register.
    3. Set the TxIE Interrupt Enable bit in the IEC register.
  8. Set the ON Control bit (TxCON[15] = 1) to enable the timer.

32-bit Asynchronous Counter Mode Code

/*	32-bit Asynchronous Counter Mode Example */
T1CON = 0x0;                     // Stops the Timer1 and resets the control register
TMR1 = 0x0;                      // Clear timer register
T1CON = 0x00000002;              // Set prescaler 1:1, external clock, asynchronous mode
PR1 = 0xFFFFFFFF;                // Load period register
T1CONbits.ON = 1;               // Start timer