
Using Timers to Measure Time
As is shown in the previous chart, four bits (two for each timer) are used to specify a mode of operation. The modes of operation are shown in Table 8−2.
Table 8−2. Timer Modes and Usage
TxM1 | TxM0 | Timer | Description of Timer Mode | Timer 1 | Timer 0 |
|
| Mode |
|
|
|
|
|
|
|
|
|
0 | 0 | 0 | Y | Y | |
|
|
|
|
|
|
0 | 1 | 1 | Y | Y | |
|
|
|
|
|
|
1 | 0 | 2 | Y | Y | |
|
|
|
|
|
|
1 | 1 | 3 | Two | N | Y |
|
|
|
|
|
|
The TMOD.GATE bit controls gating of the timer/counter. If TMOD.GATE is cleared, the timer/counter increments only if TCON.TRx is set. If TMOD.GATE is set, the timer/counter increments only if TCON.TRx is set and the corre- sponding INTx pin is held high. This feature can be used for pulse width mea- surements.
The TMOD.CT bit selects counter or timer operation. If TMOD.CT is cleared, the timer/counter register is incremented on either fosc/4 or fosc/12 (based on
the state of CKCON.TxM ). If TMOD.CT is set, the timer/counter register is in- cremented by the Tx pin.
8.3.3.113-Bit Time Mode (mode 0)
Timer mode 0 is a
In this mode, the timer/counter uses five bits of the TLx register and all eight bits of the THx register for the