6
Timer
6 – 3
6.3
RESOLUTION
TSCALE provides the capability to program longer time intervals between
interrupts, extending the range of the 16-bit TCOUNT register. Table 6.1
shows the range and the relationship between period length and
resolution for TPERIOD = maximum.
Cycle Time = 80 ns
TSCALE
Interrupt Every…
Resolution
0
5.24 ms
80 ns
255
1.34 s
20
µ
s
Table 6.1 Timer Range And Resolution
6.4
TIMER OPERATION
Table 6.2 shows the effect of operating the timer with TPERIOD = 5,
TSCALE = 1 and TCOUNT = 5. After the timer is enabled (cycle n–1) the
counter begins. Because TSCALE is 1, TCOUNT is decremented on every
other cycle. The reloading of TCOUNT and continuation of the counting
occurs, as shown, during the interrupt service routine.
Cycle
TCOUNT
Action
n–4
TPERIOD loaded with 5
n–3
TSCALE loaded with 1
n–2
TCOUNT loaded with 5
n–1
5
ENA TIMER executed
n
5
since TSCALE = 1, no decrement
n+1
5
decrement TCOUNT
n+2
4
no decrement
n+3
4
decrement TCOUNT
n+4
3
no decrement
n+5
3
decrement TCOUNT
n+6
2
no decrement
n+7
2
decrement TCOUNT
n+8
1
no decrement
n+9
1
decrement TCOUNT
n+10
0
no decrement
n+11
0
zero reached, interrupt occurs
load TCOUNT from TPERIOD
n+12
5
no decrement
n+13
5
decrement TCOUNT
n+14
4
no decrement
n+15
4
decrement TCOUNT, etc..
Table 6.2 Example Of Timer Operation