Chapter 7
16-bit Timers
VII - 60
16-bit Timer Synchronous Output
7-11-2
Setup Example
nSynchronous Output Setup Example (Timer 7)
Here is an example to output the port 4 latch data from the synchronous output pin constantly (in every
100 s) with timer 7. As a clock source of timer 7, fs/4 (fosc=8 MHz) is selected.
An example setup procedure, with a description of each step is shown below.
(1)
Set the TM7EN flag of the timer 7 mode
register 1 (TM7MD1) to "0" to stop timer 7
counting.
(2)
Set the SYOEVS1-0 flag of the pin control
register (FLOAT) to "01" to set the
synchronous output event to the timer 7
interrupt.
(3)
Set the port 4 synchronous output control
register (P4SYO) to x'FF' to set the
synchronous output pin.
(P47 to P40 : Synchronous output pin)
Set the port4 direction control register
(P4DIR) to x'FF' to set port 4 to output pin.
Add pull-up resistor, if necessary.
(4)
Set the TM7BCR flag of the TM7MD2 register
to "1" to select the compare match as the clear
source for the binary counter.
(5)
Select fs as a clock source by the TM7CK1-0
flag of the TM7MD1 register.
Also, select 1/4 dividing as a clock source by
the TM7PS1-0 flag.
(6)
Set the synchronous output event generation
cycle to the timer 7 preset register 1
(TM7PR1). To set 10 kHz by dividing
1 MHz, set as;
100 - 1 = 99 (x'0063')
At the same time, the same value is loaded to
the timer 7 compare register 1 (TM7OC1), and
TM7BC is initialized to x'0000'.
Setup Procedure
(1)
Stop the counter.
TM7MD1 (x'3F78')
bp4
: TM7EN
= 0
(2)
Select the synchronous output
event.
FLOAT (x'3F2E')
bp1-0
: SYOEVS1-0 = 01
(3)
Set the synchronous output pin.
P4SYO (x'3F1E')
= x'FF'
P4DIR (x'3F34')
= x'FF'
(4)
Select the timer clear factor.
TM7MD2 (x'3F79')
bp5
: TM7BCR
= 1
(5)
Select the count clock source.
TM7MD1 (x'3F78')
bp1-0
: TM7CK1-0 = 01
bp3-2
: TM7PS1-0 = 10
(6)
Set the synchronous output event
generation cycle.
TM7PR1 (x'3F75',x'3F74')=x'0063'
Description
[
Chapter 4
I/O Ports ]