Previously, I covered the Timer 0 module which is much easier to use and configure. Timer 1, 3, or 5 module is more complicated and lots more to configure as it provides more features.
Timer 1/3/5 Module Block Diagram
Timer 1/3/5 module is quite similar to Timer 0 except it is a 16-bit timer and an additional Gate Control input feature. What is Gate Control? Timer 1/3/5 module can be configured to count freely or disabled/enabled counter via Gate circuitry. The Gate circuitry can be driven from multiple sources selected via TxGSS<1:0> bits in TxGCON register (refer to block diagram upper corner top left). They are,
Timer 1/3/5 Gate Pin
If TxG gate pin is selected as the source, an external source will be used to enable/disable the count.
Timer 2/4/6 Match to PR2/4/6
The free counter Timer 2/4/6 register will increment until it matches with user set value in the PR2/4/6 register (Period Register). When match happens the Timer 2/4/6 will reset to zero on the next increment and a low-to-high pulse will be asserted to the Timer 1/3/5 Gate circuitry.
For example, user set the PR2 = AA55h. Assume Timer 2 counts from 00h, once Timer 2 match the preset PR2 value AA55h, the comparator in the Timer 2 module will generates a match signal which will be used to assert the Timer 1/3/5 Gate module circuitry if this source is selected.
Comparator Output sync_CxOUT
Comparator module output (sync_CxOut) can be selected as one of the Gate circuitry source. When the comparator condition is met, sync_CxOut will be asserted to Timer 1/3/5 Gate circuitry. The asserted signal will be latched on the falling edge of clock source whereas the timer increment is latched on the rising edge of clock source in order to prevent from race condition.
Unlike Timer 0, Time 1/3/5 is a 16-bit timer where the timer value is accessed through TMRxH and TMRxL. Writing to TMRxH or TMRxL will update the timer. One can choose either internal or external clock source. When internal clock source is chosen the timer increment on every instruction clock cycle compared to external clock source where the timer increment on every rising edge of clock input to the TxCKI pin. Some Microchip MCU do support secondary low-power 32.768 kHz clock oscillator which is normally used for real time clock.
No comments:
Post a Comment