
172
CHAPTER 7 16-BIT TIMER/EVENT COUNTER 4
User
’
s Manual U14701EJ3V0UD
7.5.2 Square-wave output operation
A square wave with any selected frequency is output at intervals of the value preset to 16-bit timer compare register
4 (CR4).
TO4 pin output status is reversed at intervals of the count value preset to CR4 by setting bit 7 (TCE4) of 16-bit
timer mode control register 4 (TMC4) to 1. This enables a square wave with any selected frequency to be output
(duty = 50%).
[Setting]
<1>
Set each register.
Set port latch and port mode register to 0.
TCL41, 40: Select count clock
CR4:
Compare value
TMM4:
Clear & start mode by match of TM4 and CR4 (TMM4 = 0)
LVS4:
Set initial status of timer output (TO4)
Initial output = 1
←
LVS4 = 1
Initial output = 0
←
LVS4 = 0
TMO4:
Timer output is set to enable (TMO4 = 1)
After TCE4 = 1 is set, count operation starts.
Timer output F/F is reversed by match of TM4 and CR4. After INTTM4 is generated, TM4 is cleared to 00H.
Timer output F/F is reversed at the same interval and square wave is output from TO4.
<2>
<3>
<4>
Caution The rising edge of the first clock immediately after setting TCE4 to 1 is not counted.
Count operation is started from the rising edge of the second clock.
Figure 7-5. Square-Wave Output Operation Timing
Count clock
TM4 count value
CR4
TO4
Note
TCE4 = 1
0000H
0001H
N
–
1
N
0000H 0001H 0002H
N
–
1
N
0000H
N
Note
TO4 output initial value can be set by bit 4 (LVS4) of 16-bit timer mode control register 4 (TMC4).