Chapter 8
8-bit Timer
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
1
Disable the timer counter
2
Disable the interrupt
3
Select the event input
4
5
Set the interrupt cycle
Set the timer mode register
6
7
9
Set the interrupt level
10
Enable the interrupt
11
Enable the timer counter
VIII - 22
8-bit Event Count
Register
TM0MD.TM0EN = 0
TM0ICR.TM0IE = 0
TMIOSEL0.TM0IOSEL0 = 0
P0DIR.P0DIR5 = 0
TM0OC = 0x04
TM0MD.TM0PWM = 0
TM0MD.TM0MOD = 0
TM0MD.TM0CK1-0 = 11
TM0ICR.TM0LV1-0
TM0ICR.TM0IE = 1
TM0MD.TM0EN = 1
Description
Disable the timer count operation.
Disable the timer interrupt.
Select the event clock input pin.
[Chapter 7 I/O Port]
Set the interrupt generation cycle.
Select the timer normal operation.
Select TM0IO input as the count clock source.
Refer to [3.1.3 Maskable Interrupt Control Register Setup].
Enable the timer count operation.