![](http://datasheet.mmic.net.cn/380000/-PD78F9117Y_datasheet_16745013/-PD78F9117Y_128.png)
CHAPTER 7 8-BIT TIMER/EVENT COUNTER
127
7.4.3 Operation as square wave output
The 8-bit timer/event counter can generate output square waves of an arbitrary frequency at intervals specified
by the count value set in 8-bit compare registers 80, 81, and 82 (CR80, CR81, and CR82) in advance.
To operate 8-bit timer/event counters 80, 81, and 82 for square wave output, the following settings are required.
Set P26, P31, and P33 to output mode (PM26 = 0, PM31 = 0, PM33 = 0).
Reset output latches of P26, P31, and P33 to 0.
Set count value in CR80, CR81, and CR82.
Set 8-bit timer mode control registers 80, 81, and 82 (TMC80, TMC81, and TMC82) as shown in Figure 7-13.
Figure 7-13. Settings of 8-Bit Timer Mode Control Register 8n for Square Wave Output Operation
When the count value of 8-bit timer register 8n (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, TM8n will be cleared to 0 and resumes to count, generating an interrupt request signal (INTTM8n).
Setting 0 for bit 7 (TCE8n) of TMC8n clears the square-wave output to 0.
Tables 7-11 through 7-13 show square wave output range, and Figure 7-14 shows timing of square wave output.
Remark
n = 0 to 2
Table 7-11. Square Wave Output Range of 8-Bit Timer/Event Counter 80
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)
Remarks 1.
f
X
: Main system clock oscillation frequency
2.
The parenthesized values apply to operation at f
X
= 5.0 MHz.
Table 7-12. Square Wave Output Range of 8-Bit Timer/Event Counter 81
TCL811
TCL810
Minimum Pulse Width
Maximum Pulse Width
Resolution
0
0
2
4
/f
X
(3.2
μ
s)
2
12
/f
X
(819.2
μ
s)
2
4
/f
X
(3.2
μ
s)
0
1
2
8
/f
X
(51.2
μ
s)
2
16
/f
X
(13.1 ms)
2
8
/f
X
(51.2
μ
s)
Remarks 1.
f
X
: Main system clock oscillation frequency
2.
The parenthesized values apply to operation at f
X
= 5.0 MHz.
1
0
0
0
0
0
0/1
1
TMC8n
TCE8n
TCL8n1 TCL8n0
TOE8n
Setting of count clock (see
Tables 7-11
through
7-13
)
8-bit timer register 8n (TM8n) operation enable
PWME8n
PWM output disable
TO8n output enable