CHAPTER 9 8-BIT TIMERS 30 AND 40
User’s Manual U14826EJ5V0UD
100
(3) Operation as square-wave output wit 8-bit resolution (timer 40 only)
Square waves of any frequency can be output at an interval specified by the value preset in 8-bit compare
register 40 (CR40).
To operate timer 40 for square-wave output, settings must be made in the following sequence.
<1> Set P20 to output mode (PM20 = 0).
<2> Clear the output latches of P20 to 0.
<3> Disable operation of 8-bit timer counter 40 (TM40) (TCE40 = 0).
<4> Set a count clock for timer 40 and enable output of TMO (TOE40 = 1).
<5> Set a count value in CR40.
<6> Enable the operation of TM40 (TCE40 = 1).
When the count value of TM40 matches the value set in CR40, the TMO pin output will be inverted. Through
application of this mechanism, square waves of any frequency can be output. As soon as a match occurs,
TM40 is cleared to 00H and continues counting. At the same time, an interrupt request signal (INTTM40) is
generated.
The square-wave output is cleared to 0 by setting TCE40 to 0.
Tables 9-7 and 9-8 show the square-wave output range, and Figure 9-15 shows the timing of square-wave
output.
Caution Be sure to stop the timer operation before overwriting the count clock with different data.
Table 9-7. Square-Wave Output Range of Timer 40 (During f
X
= 5.0 MHz Operation)
TCL402 TCL401 TCL400
Minimum Pulse Width
Maximum Pulse Width
Resolution
0 0 0
1/f
X
(0.2
µ
s)
2
8
/f
X
(51.2
µ
s)
1/f
X
(0.2
µ
s)
0 0 1
2
2
/f
X
(0.8
µ
s) 2
10
/f
X
(204.8
µ
s) 2
2
/f
X
(0.8
µ
s)
Remark
f
X
: System clock oscillation frequency (ceramic/crystal oscillation)
Table 9-8. Square-Wave Output Range of Timer 40 (During f
CC
= 1.0 MHz Operation)
TCL402 TCL401 TCL400
Minimum Pulse Width
Maximum Pulse Width
Resolution
0 0 0
1/f
CC
(1.0
µ
s)
2
8
/f
CC
(256
µ
s)
1/f
CC
(1.0
µ
s)
0 0 1
2
2
/f
CC
(4.0
µ
s) 2
10
/f
CC
(1024
µ
s) 2
2
/f
CC
(4.0
µ
s)
Remark
f
CC
: System clock oscillation frequency (RC oscillation)