![](http://datasheet.mmic.net.cn/380000/-PD78196Y_datasheet_16744919/-PD78196Y_161.png)
CHAPTER 10 8-BIT TIMER/EVENT COUNTER
161
10.4.3 Operation as square wave output
The 8-bit timer/event counter can generate output square waves of a given frequency at intervals specified by the
count value set to the 8-bit compare registers 80, 81, and 82 (CR80, CR81, and CR82) in advance.
To operate the 8-bit timer/event counters 80, 81, and 82 for square wave output, the following settings are
required.
Set port mode registers 2 and 3 (PM26, PM31, and PM33) to output mode.
Set count value to CR80, CR81, and CR82.
Set the 8-bit timer mode control registers 80, 81, and 82 (TMC80, TMC81, and TMC82) as shown in Figure
10-13.
Figure 10-13. Settings of 8-Bit Timer Mode Control Register 8n in Square Wave Output Operation
Caution
If the TO8n pin is used as a timer output, set both port mode register and an output latch to 0
(see Table 6-3).
When the count value of an 8-bit timer (TM8n) matches the value set in CR8n, the TO8n pin output will be
inverted. Through application of this mechanism, square waves of any frequency can be output. As soon as a
match occurs, the TM8n value will be cleared to 0 then resume to count, generating an interrupt request signal
(INTTM8n).
Setting 0 to the bit 7 in TMC8n, that is, TCE8n clears the square-wave output to 0.
Tables 10-14 through 10-19 show square wave output range, and Figure 10-14 shows timing of square wave
output.
Remark
n = 0 to 2
Table 10-14. Square Wave Output Range of 8-Bit Timer/Event Counter 80 (At f
X
= 5.0 MHz)
TCL801
TCL800
Minimum Pulse Width
Maximum Pulse Width
Resolution
0
0
1/f
X
(200 ns)
2
8
/f
X
(51.2
μ
s)
1/f
X
(200 ns)
0
1
2
3
/f
X
(1.6
μ
s)
2
11
/f
X
(409.6
μ
s)
2
3
/f
X
(1.6
μ
s)
Remark
f
X
: Main system clock oscillation frequency (ceramic/crystal oscillation)
Table 10-15. Square Wave Output Range of 8-Bit Timer/Event Counter 80 (At f
CC
= 4.0 MHz)
TCL801
TCL800
Minimum Pulse Width
Maximum Pulse Width
Resolution
0
0
1/f
CC
(250 ns)
2
8
/f
CC
(64
μ
s)
1/f
CC
(250 ns)
0
1
2
3
/f
CC
(2.0
μ
s)
2
11
/f
CC
(512
μ
s)
2
3
/f
CC
(2.0
μ
s)
Remark
f
CC
: Main system clock oscillation frequency (RC oscillation)
1
0
0
0
0
0
0/1
1
TMC8n
TCE8n
TCL8n1 TCL8n0
TOE8n
Setting of count clock (see
Tables 10-14
through
10-19
)
8-bit timer register 8n (TM8n) operation enable
PWME8n
PWM output disable
TO8n output enable