TBCL0-1
TBCL0
TBCL0-1
Timer Clock
Timer
Set TBxCTL TBIFG
Set TBxCCR0 CCIFG
TBCL0-2
1h
0h
1h
Up/Down
0h
TBxCL0
Timer_B Operation
670
SLAU367P – October 2012 – Revised April 2020
Copyright © 2012–2020, Texas Instruments Incorporated
Timer_B
Time intervals can be produced with other modes as well, where TBxCL0 is used as the period register.
Their handling is more complex, because the sum of the old TBxCLn data and the new period can be
higher than the TBxCL0 value. When the sum of the previous TBxCLn value plus t
x
is greater than the
TBxCL0 data, the old TBxCL0 value must be subtracted to obtain the correct time interval.
26.2.3.4 Up/Down Mode
The up/down mode is used if the timer period must be different from TBxR
(max)
counts and if symmetrical
pulse generation is needed. The timer repeatedly counts up to the value of compare latch TBxCL0, and
back down to zero (see
). The period is twice the value in TBxCL0.
NOTE:
TBxCL0 > TBxR
(max)
If TBxCL0 > TBxR
(max)
, the counter operates as if it were configured for continuous mode. It
does not count down from TBxR
(max)
to zero.
Figure 26-7. Up/Down Mode
The count direction is latched. This allows the timer to be stopped and then restarted in the same direction
it was counting before it was stopped. If this is not desired, the TBCLR bit must be used to clear the
direction. Setting TBCLR also clears the TBxR value and the clock divider counter logic (the divider setting
remains unchanged).
In up/down mode, the TBxCCR0 CCIFG interrupt flag and the TBIFG interrupt flag are set only once
during the period, separated by one-half the timer period. The TBxCCR0 CCIFG interrupt flag is set when
the timer
counts
from TBxCL0-1 to TBxCL0, and TBIFG is set when the timer completes
counting
down
from 0001h to 0000h.
shows the flag set cycle.
Figure 26-8. Up/Down Mode Flag Setting
26.2.3.4.1 Changing the Value of Period Register TBxCL0
When changing TBxCL0 while the timer is running and counting in the down direction, and when the
TBxCL0 load mode is
immediate
, the timer continues its descent until it reaches zero. The new period
takes effect after the counter counts down to zero.