
175
CHAPTER 7
8-BIT TIMER/EVENT COUNTERS 50, 51
User’s Manual U12790EJ2V0UD
7.4.3 Square-wave output operation (8-bit resolution)
The 8-bit timer/event counter (TM5n) can be used to output a square wave with any frequency at time intervals
specified by the value preset to 8-bit compare register 5n (CR5n).
When bit 0 (TOE5n) of 8-bit timer mode control register 5n (TMC5n) is set to 1, the output status of TO5n is inverted
at the interval specified by the count value preset to CR5n. In this way, a square wave (duty factor = 50%) of any
frequency can be output.
[Setting]
<1> Set each register.
Reset the port latches (P130 and P131) to “0”.
TCL5n: Select a count clock.
CR5n:
Set a compare value.
TMC5n: Select clear & start mode on match between TM5n and CR5n.
LVS5n LVR5n
Setting of status of timer output F/F
1
0
High-level output
0
1
Low-level output
Enable inverting the timer F/F.
Enable the timer output
→ TOE5n = 1.
<2> When TCE5n is set to 1, the count operation is started.
<3> When the value of TM5n matches as the value of CR5n, the timer output F/F is inverted.
In addition, INTTM5n is generated, and TM5n is cleared to 00H.
<4> After that, the timer output F/F is inverted at fixed intervals, and a square wave is output from TO5n.
Remark
n = 0 or 1
Figure 7-10. Timing of Square-Wave Output Operation
Note
The initial value of TO5n output can be set by using bits 2 and 3 (LVR5n and LVS5n) of 8-bit timer mode
control register 5n (TMC5n).
Remark
n = 0 or 1
TM5n count value
Count starts
Count clock
00H
01H
02H
N
1N
N
00H
N
1
N
00H
01H
02H
CR5n
INTTM5n
TO5nNote