VI - 33
Chapter 6
8-bit Timers
Synchronous Output
6-7-2
Setup Example
nSynchronous Output Setup Example (Timer 1, Timer 2)
Setup example that latch data of port 4 is output constantly (100 s) by using timer 2 from the synchro-
nous output pin is shown below. The clock source of timer 2 is selected fs/4 (fosc=8 MHz at operation).
A setup procedure example, with a description of each step is shown below.
(1)
Set the TM2EN flag of the timer 2 mode
register (TM2MD) to "0" to stop the timer 2
counting.
(2)
Set the SYOEVS1-0 flag of the pin control
register (FLOAT) to "10" to set the
synchronous output event to timer 2 interrupt.
(3)
Set the port 4 synchronous output control
register (P4SYO) to x'FF' to set the
synchronous output pin.
(P47 to P40 are synchronous output pin.)
Set the port 4 direction control register
(P4DIR) to x'FF' to set port 4 to output mode.
Add pull-up resistor, if necessary.
(4)
Set the TM2PWM flag and TM2MOD flag of
the TM2MD register to "0" to select the
normal timer operation.
(5)
Select the prescaler output for clock source by
TM2CK2-0 flag of the TM2MD register.
(6)
Select fs/4 for the prescaler output by
TM2BAS flag, TM2PSC1-0 of the timer 2
prescaler selection register (CK2MD).
Also, set the PSCEN flag of the prescaler
control register (PSCMD) to "1" to enable the
prescaler counting.
Setup Procedure
(1)
Start the counter.
TM2MD (x'3F5C')
bp3
:TM2EN
= 0
(2)
Select the synchronous output
event.
FLOAT (x'3F2E')
bp1-0
:SYOEVS1-0 = 10
(3)
Set the synchronous output pin.
P4SYO (x'3F1F')
= x'FF'
P4DIR (x'3F3D')
= x'FF'
(4)
Select the normal timer operation.
TM2MD (x'3F5C')
bp4
:TM2PWM = 0
bp5
:TM2MOD
= 0
(5)
Select the count clock source.
TM2MD (x'3F5C')
bp2-0
:TM2CK2-0 = 001
(6)
Select the prescaler output and
enable counting.
CK2MD (x'3F5E')
bp2-1
:TM2PSC1-0 = 01
bp0
:TM2BAS
= 1
PSCMD (x'3F6F')
bp0
:PSCEN
= 1
Description
[
Chapter 4. I/O Ports ]