![](http://datasheet.mmic.net.cn/120000/ML66525-XXTB_datasheet_3559839/ML66525-XXTB_302.png)
Chapter 9
16-bit Timer
IX - 70
External Trigger
9.11.2
Setup Example
■ External Trigger Setup Example
Timer 8 can be activated at the rising edge of the external input pin (TM8AIO) . The count clock operates in 1 ms
with selecting IOCLK. After 1 ms operation, the count clock stops timer operation and operates for 1 ms again at
the rising edge of the external input pin as well.
The count clock generates matching the binary counter and the compare/capture register. The oscillation fre-
quency is 10 MHz, 6 multiplication and IOCLK=MCLK/2. An setup procedure with a description of each step is
shown below.
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 repeating cycle
TM8CA(0x0000A208)=0x752F
(2) Set the repeating cycle to the timer 8 compare/capture A
register (TM8CA). The setting value is 29999 (0x752F)
due to 30000.
(3) Select the count source
TM8MD(0x0000A200)
bp2-0: TMCK2-0=000
(3) Select the count clock source (IOCLK) by the TMCK2-0
flag of the TM8MD register.
(4) Select the timer up or 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 enable
TM8MD(0x0000A200)
bp11: TMCLE=1
(5) Set the TMCLE flag of the TM8MD register to “1” to
enable clear operation of the TM8BC counter. When
the TM8CA register and the TM8BC counter match, the
TM8BC counter is cleared.
(6) Set the timer external trigger enable
TM8MD(0x0000A200)
bp13: TMTGE=1
(6) Set the TMTGE flag of the TM8MD register to “1” to
enable timer activation from the external input pin.
(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) Select the timer A pin polarity
TM8MDA(0x0000A204)
bp5: TMAEG=1
(8) Set the TMAEG flag of the TM8MDA register to “1”. The
timer is activated at the rising edge of the input pin.
(9) Set the input pin (pin function)
P3MD(0x0000A033)
bp0: P36M=1
(9) Set the P36M flag of the port 3 output mode register
(P3MD) to “1” to set pin function.