25.4.8 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 TON Control bit (TxCON[15] = 0) to disable the timer.
  2. Set the TCS bit (TxCON[1] = 1) to enable external clock selection.
  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. If using period match, 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 TON 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 Timer and resets the control register
TMR1 = 0x0;                      // Clear timer register
T1CON = 0x00000102;              // Set prescaler 1:1, external clock,asynchronous mode
PR1 = 0xFFFFFFFF;                // Load period register
T1CONbits.ON = 1;                // Start timer