5/7/2023 0 Comments Pic ccp as timerHowever, special precautions in software are needed to read/write the timer. If the external clock source is selected then the timer will continue to run during Sleep and can generate an interrupt on overflow, which will wake-up the processor. The timer increments asynchronously to the internal phase clocks. If control bit T1SYNC of the T1CON register is set, the external clock input is not synchronized. The TMR1IF flag will be set when 1024 clock cycles have elapsed, thereby indicating that the oscillator is running and reasonably stable.īit 3 T1OSCEN: LP Oscillator Enable Control bitġ = Secondary oscillator circuit enabled for Timer1Ġ = Secondary oscillator circuit disabled for Timer1 Timer1 Operation in Asynchronous Counter Mode A suitable delay similar to the OST delay can be implemented in software by clearing the TMR1IF bit then presetting the TMR1H:TMR1L register pair to FC00h. Thus, T1OSCEN should be set and a suitable delay observed prior to using Timer1. The oscillator requires a start-up and stabilization time before use. The oscillator will continue to run during Sleep. The secondary oscillator circuit is enabled by setting the T1OSCEN bit of the T1CON register. The secondary oscillator is designed to use an external 32.768 kHz crystal. Timer1 uses the low-power secondary oscillator circuit on pins SOSCI and SOSCO. The prescale counter is not directly readable or writable however, the prescaler counter is cleared upon a write to TMR1H or TMR1L.īit 5-4 T1CKPS: Timer1 Input Clock Prescale Select bitsĠ0 = 1:1 Prescale value Secondary Oscillator: The T1CKPS bits of the T1CON register control the Prescale counter. Timer1 has four prescaler options allowing 1, 2, 4 or 8 divisions of the clock input. When used as a timer with a clock oscillator, an external 32.768 kHz crystal can be used in conjunction with the secondary oscillator circuit. This external clock source can be synchronized to the microcontroller system clock and run asynchronously. When enabled to count, Timer1 is incremented on the rising edge of the external clock input T1CKI. When the external clock source is selected, the Timer1 module may work as a timer or a counter. To utilize the full resolution of Timer1, an asynchronous input signal must be used to gate the Timer1 clock input. Due to this condition, a 2 LSB error in resolution will occur when reading the Timer1 value. When the FOSC internal clock source is selected, the Timer1 register value will increment by four counts every instruction clock cycle. Of FOSC as determined by the Timer1 prescaler. When the internal clock source is selected the TMR1H:TMR1L register pair will increment on multiples When the external clock source is selected, the timer may operate either as a timer or a counter.Ĭlock pulses in the counter mode can be synchronized with the microcontroller internal clock or run asynchronously. When used as a timer with a clock oscillator, an external 32.768 kHz crystal can be used in conjunction with the secondary oscillator circuit The TMR1CS and T1OSCEN bits of the T1CON register are used to select the clock source for Timer1. Timer1 is enabled by configuring the TMR1ON and TMR1GE bits in the T1CON and T1GCON registers, respectively. When used with an external clock source, the module can be used as either a timer or counter and increments on every selected edge of the external source. When used with an internal clock source, the module is a timer and increments on every instruction cycle. Writes to TMR1H or TMR1L directly update the counter. The Timer1 module is a 16-bit incrementing counter which is accessed through the TMR1H:TMR1L register Below is the functional block diagram for your reference.īefore configuring Timer1 Lets us discuss in brief about Timer1 operation, features and few other parameters which will help us while programming the Timer1 in PIC controller with MPLAB XIDE.
0 Comments
Leave a Reply. |