Chapter 9
16-bit Timer
1-Shot Output
IX - 67
9.10.2
Setup Example
■ 1-Shot Output Setup Example
As taking an example of the timer 8, it is explained that timers can operate 1 ms one time. Select IOCLK as clock
source to match the binary counter and the compare/capture register after 1ms . The oscillation frequency is 10
MHz, 6 multiplication and IOCLK=MCLK/2. A setup procedure with a description of each step is shown below.
TM8BC counter counts up. When the TM8BC counter and the TM8CA register match, the timer operation stops
at the rising edge of the next count clock. The TMXF flag indicates “0”. The value of the TM8BC counter is ini-
tialized to 0x0000 and counting up stops. Set the TMCNE flag to “1” again after setting it to “0” again to restart.
Setup Procedure
Description
(1) Stop the counter
TM8MD(0x0000A200)
bp6: TMLDE=0
bp7: TMCNE=0
(1) Set the TMLDE flag and the TMCNE flag of the timer 8
mode register (TM8MD) to “0” to stop the timer 8
counting.
(2) Set the count cycle
TM8CA(0x0000A208)=0x752F
(2) Set the count cycle to the timer 8 compare/capture A
register (TM8CA). Due to 30000 counts, the setting
value is 29999 (0x752F).
(3) Select the count clock source
TM8MD(0x0000A200)
bp2-0: TMCK2-0=000
(3) Select the TMCK2-0 flag of the TM8MD register to the
count clock source (IOCLK).
(4) Select the timer up/down
TM8MD(0x0000A200)
bp9-8: TMUD1-0=00
(4) Select the timer up counting by the TMUD1-0 flag of the
TM8MD register.
(5) Set the timer counter clear enabled
TM8MD(0x0000A200)
bp11: TMCLE=1
(5) Set the TMCLE flag of the TM8MD register to “1” to
enable clear operation of the TM8MD counter. When
the TM8CA register and the TM8BC counter match, the
TM8BC counter is cleared.
(6) Set the 1-shot operation enabled
TM8MD(0x0000A200)
bp12: TMONE=1
(6) Set the TMONE flag of the TM8MD register to “1” to
enable1-shot operation.
(7) Select the timer compare/capture A
operation mode
TM8MDA(0x0000A204)
bp7-6: TMAM1-0=00
(7) Set the function of the timer 8 compare/capture register
to the compare register (double buffer) by the TMAM1-
0 flag of the timer 8 compare/capture A mode register
(TM8MDA).
(8) Initialize the timer 8
TM8MD(0x0000A200)
bp6: TMLDE=1
(8) Set the TMLDE flag of the TM8MD register to “1” to
initialize the timer 8. The value of the compare register
buffer is loaded into the TM8CA register. Reset the
TMLDE flag to “0” after setting.
(9) Start the timer operation
TM8MD(0x0000A200)
bp7: TMCNE=1
(9) Set the TMCNE flag of the TM8MD register to “1” to
operate the timer 8.