8-bit PIC® MCU Timer1 Clock Source

Last modified by Microchip on 2023/11/22 16:33

The Timer1 Clock Source is the input signal that increments the Timer1 counter. The clock source is selected by the Timer1 Clock Select (TMR1CS<1:0>) bits in the T1CON register.

Timer 1 Clock Source

There are four clock selections which include:

Timer 1 Clock Source Select Bits

Note: On older devices, there are only three clock source options as the fourth optional selection is not included. On those devices, the TMR1CS is a single bit in the T1CON register.

Back to Top

Fosc/4 Instruction Clock Source (00)

When the instruction clock (Fosc/4) is selected (TMR1CS <1:0> = 00), Timer1 is incremented by the system oscillator through a divide by four scalers (Fosc/4). The TMR1H:TMR1L register pair will be incremented on the rising edge of the instruction clock. Any reads of the TMR1H:TMR1L registers are done based on this Fosc/4 instruction clock.

Back to Top

Fosc System Clock Source (01)

The Fosc is the system oscillator. When the Fosc system clock is selected (TMR1CS <1:0> = 01) as the Timer1 Clock Source, Timer1 is incremented by the system oscillator clock directly. The TMR1H:TMR1L register pair will be incremented on the rising edge of the oscillator clock. One thing to recognize is that any reads of the TMR1H:TMR1L registers are done based on the instruction clock (Fosc/4), even when the Fosc is selected as the Timer1 clock. When the Fosc internal clock source is selected, the Timer1 register value will increment by four counts for every instruction clock cycle. Due to this condition, a 2 LSB error in resolution will occur when reading the Timer1 value.

Back to Top

External Clock Source (10)

When the external clock is selected (TMR1CS<1:0> = 10*), the Timer1 Oscillator Enable (T1OSCEN) bit selects the external signal source. The Timer1 module may work as a counter using an I/O pin as the input source, or a timer using an external 32 kHz clock oscillator.


When a counter is desired, the T1CKI input is selected by the Timer1 Oscillator Enable (T1OSCEN) bit. Timer1 is incremented on the rising edge of the external clock input signal at the T1CKI pin, which can be synchronized to the microcontroller system clock or can run asynchronously.

External 32 kHz Clock Oscillator

When a timer with a separate clock oscillator is desired, the T1OSCEN bit is set to the crystal oscillator mode. When this mode is selected, the Timer1 structure will also enable a dedicated low-power 32.768 kHz oscillator drive circuit built internally between I/O pins SOSCI (input) and SOSCO (amplifier output). This internal circuit is to be used in conjunction with an external 32.768 kHz "clock crystal". This can enable Timer1 to act as a dedicated real-time clock. The oscillator will continue to run during Sleep. More details on this option can be found at: Timer1 Secondary Oscillator.

Timer 1 Oscillator Enable Bit

Timer1 Asynchronous Mode

When the External Clock mode is selected as the Timer1 source, it can run asynchronously to the system clock. The Timer1 External Clock Input Synchronization Control bit (T1SYNC) of the T1CON register can be set to make the external clock un-synchronized. The timer will then increment asynchronously to the internal phase clocks. Running asynchronously allows the external clock source to continue incrementing the timer during Sleep and can generate an interrupt on overflow. The interrupt will wake up the processor so an internal time-based application can be updated. However, special precautions in software are needed to read/write the timer.

Timer 1 External Clock Input Synchronization Bit

Reading and Writing to Timer1 in Asynchronous Counter Mode

Reading the TMR1H or TMR1L registers while Timer1 is running from an external asynchronous clock will return a valid read value as it is taken care of in hardware. For writes, it is recommended that you simply stop the timer and write the desired values for accurate implementation.

Back to Top

Optional Fourth Clock (11)

Low-Frequency Internal Oscillator

On some devices, Timer1 can be incremented separately by the Low-Frequency Internal Oscillator. This will allow Timer1 to increment independently of the system or instruction clock.

Capacitive Sensing Oscillator

On some devices, the capacitive sensing oscillator, which consists of a constant current source and a constant current sink to produce a triangle waveform, can be used as the oscillator designed to drive a capacitive load (single PCB pad). This clock source can also be shared to be the clock source to Timer1.

Back to Top