Timer1 Clock Source

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.

timer1clk2.png

There are four clock selections which include:

*4th clock options include:
LF Internal Oscillator
Capacitive sense clock

timer1clock4.png

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.

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 scaler (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.

Fosc SYSTEM CLOCK SOURCE (01)

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.

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.

T1CKI I/O Pin
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 detail on this option can be found at: Timer1 Secondary Oscillator

timer1osc.png

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.

timer1sync.png

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's taken care of in hardware. For writes though, it is recommended that the user simply stop the timer and write the desired values for accurate implementation.

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.

20th Annual
Microchip MASTERs Conference 2016
Register now - Deadline: July 29

JW Marriott Desert Ridge Resort-Phoenix, AZ

© 2016 Microchip Technology, Inc.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.