User manual

...the world's most energy friendly microcontrollers
2012-04-24 - Giant Gecko Family - d0053_Rev0.96 583
www.energymicro.com
Figure 23.3. LETIMER One-shot Repeat State Machine
RUNNING
YES
CNT = = 0
CNT = CNT - 1
NO
REP0 < 2
YES
NO
STOP = 1
REP0 = 0
CNT = TOP*
If (!START)
REP0 = REP0 - 1
If (STOP)
RUNNING = 0
Else if (START)
RUNNING = 1
End if
START = 0
STOP = 0
Wait for positive clock edge
YES
If (!COMP0TOP)
TOP** = 0xFFFF
Else if (COMPBUF)
TOP** = COMP1
Else
TOP** = COMP0
If (COMP0TOP)
TOP* = COMP0
Else
TOP* = 0xFFFF
TOP*
TOP**
START
YES
CNT = = 0
REP0 = = 0
YES
CNT = CNT - 1
CNT = TOP*
NO
NO
YES
NO
NO
23.3.3.2.3 Buffered Mode
The Buffered repeat mode allows buffered timer operation. When started, the timer runs
LETIMERn_REP0 number of times. If LETIMERn_REP1 has been written since the last time it was used
and it is nonzero, LETIMERn_REP1 is then loaded into LETIMERn_REP0, and counting continues the
new number of times. The timer keeps going as long as LETIMERn_REP1 is updated with a nonzero
value before LETIMERn_REP0 is finished counting down.
If the timer is started when both LETIMERn_CNT and LETIMERn_REP0 are zero but LETIMERn_REP1
is non-zero, LETIMERn_REP1 is loaded into LETIMERn_REP0, and the counter counts the loaded
number of times. The state machine for the one-shot repeat mode is shown in Figure 23.3 (p. 583) .
Used in conjunction with a buffered top value, enabled by setting BUFTOP in LETIMERn_CTRL, the
buffered mode allows buffered values of both the top and repeat values of the timer, and the timer can
for instance be set to run 4 times with period 7 (top value 6), 6 times with period 200, then 3 times with
period 50.
A state machine for the buffered repeat mode is shown in Figure 23.4 (p. 584) . REP1
USED
shown in the
state machine is an internal variable that keeps track of whether the value in LETIMERn_REP1 has been
loaded into LETIMERn_REP0 or not. The purpose of this is that a value written to LETIMERn_REP1
should only be counted once. REP1
USED
is cleared whenever LETIMERn_REP1 is written.