Panasonic MN101C77C Cell Phone User Manual


 
Chapter 6 8-bit Timers
VI - 24
8-bit Timer Pulse Output
6-5-2 Setup Example
Timer Pulse Output Setup Example (Timers 0, 1, 4 and 5)
TM0IO (P10) pin outputs 50 kHz pulse by using timer 0. For this, select fosc as clock source, and set a 1/
2 cycle (100 kHz) for the timer 0 compare register (at fosc=20 MHz).
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 P1OMD0 flag of the port 1 output mode
register (P1OMD) to "1" to set P10 the special
function pin.
Set the P1DIR0 flag of the port 1 direction
control register (P1DIR) to "1" to set output
mode.
If it needs, pull-up resister 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 fosc for the clock source by the
TM0CK2-0 flag of the TM0MD register.
(5) Set the timer 0 compare register (TM0OC) to
the 1/2 of the timer pulse output cycle.
The setting value should be 200-1=199(x'C7'),
because 100 kHz is divided by 20 MHz.
At that time, the timer 0 binary counter
(TM0BC) is initialized to x'00'.
(6) Set the TM0EN flag of the TM0MD register to
"1" to start timer 0.
Setup Procedure
(1) Stop the counter.
TM0MD (x'3F54')
bp3 :TM0EN = 0
(2) Set the special function pin to the
output mode.
P1OMD (x'3F2F')
bp0 :P1OMD0 = 1
P1DIR (x'3F31')
bp0 :P1DIR0 = 1
(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 = 000
(5) Set the timer pulse output cycle.
TM0OC (x'3F52') = x'C7'
(6) Start the timer operation.
TM0MD (x'3F54')
bp3 :TM0EN = 1
Description
[ Chapter 4. I/O Ports ]