Panasonic F77G Cell Phone User Manual


 
VI - 21
Chapter 6 8-bit Timers
8-bit Event Count
6-4-2 Setup Example
Event Count Setup Example (Timers 0, 1, 4 and 5)
If the falling edge of the TM0IO input pin signal is detected 5 times with using timer 0, an interrupt is
generated.
An example setup procedure, with a description of each step is shown below.
(1) Set the TM0EN flag of the timer 0 mode
register (TM0MD) to "0" to stop timer 0
counting.
(2) Set the P1DIR1 flag of the port 1 direction
control register (P1DIR) to "0" to set P11 pin to
input mode.
If it needs, pull up resistor should be added.
(3) Set the TM0PWM flag and TM0MOD flag of
the TM0MD register to "0" to select the normal
timer operation.
(4) Select the clock source to TM0IO input by the
TM0CK2-0 flag of the TM0MD register.
(5) Set the timer 0 compare register (TM0OC) the
interrupt generation cycle. Counting is 5, so
the setting value should be 4.
At that time, the timer 0 binary counter
(TM0BC) is initialized to x'00'.
(6) Set the interrupt level by the TM0LV1-0 flag
of the timer 0 interrupt control register
(TM0ICR).
If the interrupt request flag may be already set,
cancel all existing interrupt requests.
Setup Procedure
(1) Stop the counter.
TM0MD (x'3F54')
bp3 :TM0EN = 0
(2) Set the special function pin to input.
P1DIR (x'3F31')
bp0 :P1DIR1 = 0
(3) Select the normal timer operation.
TM0MD (x'3F54')
bp4 :TM0PWM = 0
bp5 :TM0MOD = 0
(4) Select the count clock source.
TM0MD (x'3F54')
bp2-0 :TM0CK2-0 = 110
(5) Set the interrupt generation cycle.
TM0OC (x'3F52') = x'04'
(6) Set the interrupt level.
TM0ICR (x'3FE9')
bp7-6 :TM0LV1-0 = 10
Description
[ Chapter 3 3-1-4. Interrupt Flag Setup ]
[
Chapter 4. I/O Ports ]