Chapter 8
8-bit Timer
VIII - 22 8-bit Event Count
8.4.2 8-bit Event Count Setup Example
Event Count Setup Example
Here is an example that an interrupt is generated by detecting the falling edge of the TM0IO input 5 times.
The setup procedure and the description of each step are shown below.
Step Setting Register Description
1 Disable the timer counter TM0MD.TM0EN = 0 Disable the timer count operation.
2 Disable the interrupt TM0ICR.TM0IE = 0 Disable the timer interrupt.
3 Select the event input TMIOSEL0.TM0IOSEL0 = 0 Select the event clock input pin.
[Chapter 7 I/O Port]
4 P0DIR.P0DIR5 = 0
5 Set the interrupt cycle TM0OC = 0x04 Set the interrupt generation cycle.
6
Set the timer mode register TM0MD.TM0PWM = 0
TM0MD.TM0MOD = 0
Select the timer normal operation.
7 TM0MD.TM0CK1-0 = 11 Select TM0IO input as the count clock source.
9 Set the interrupt level TM0ICR.TM0LV1-0 Refer to [3.1.3 Maskable Interrupt Control Register Setup].
10 Enable the interrupt TM0ICR.TM0IE = 1
11 Enable the timer counter TM0MD.TM0EN = 1 Enable the timer count operation.