
CHAPTER 9 8-BIT TIMER/EVENT COUNTERS 80 TO 82
User’s Manual U14186EJ6V0UD
145
9.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 8n (CR8n) in advance.
To operate 8-bit timer/event counters 8n for square wave output, the following settings are required.
<1> Set P26, P31, or P33 to output mode (PM26 = 0, PM31 = 0, PM33 = 0).
<2> Reset the output latches of P26, P31, or P33 to 0.
<3> Set 8-bit timer counter 8n (TM8n) to operation disable (by setting TCE8n (bit 7 of 8-bit timer mode control
register 8n (TMC8n)) to 1).
<4> Set the count clock of 8-bit timer/event counter 8n and set TO8n to output enable (TOE8n (bit 0 of TMC8n) =
1).
<5> Set count value in CR8n.
<6> Set TM8n to operation enable (TCE8n = 1).
When the count value of 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 00H 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 9-11 through 9-13 show square wave output range, and Figure 9-11 shows timing of square wave output.
Cautions 1. Before rewriting CR8n, stop the timer operation once.
If CR8n is rewritten in the timer
operation-enabled state, a match interrupt request signal may occur at the moment of
rewrite.
2. If the count clock setting and TM8n operation-enabled are set in TCM8n simultaneously
using an 8-bit memory manipulation instruction, an error of more than a clock in one cycle
may occur after the timer start.
Therefore, always follow the above procedure when
operating the 8-bit timer/event counter for square wave output.
Remark
n = 0 to 2
Table 9-11. Square Wave Output Range of 8-Bit Timer/Event Counter 80
TCL801
TCL800
Minimum Pulse Width
Maximum Pulse Width
Resolution
0
1/fX (100 ns) [200 ns]
2
8/fX (25.6
s) [51.2 s]
1/fX (100 ns) [200 ns]
0
1
2
3/fX (0.8
s) [1.6 s]
2
11/fX (204.8
s) [409.6 s]
2
3/fX (0.8
s) [1.6 s]
Remarks 1. fX: Main system clock oscillation frequency
2. The values in parentheses ( ) apply to operation at fX = 10.0 MHz. (expanded-specification products
only)
3. The values in brackets [ ] apply to operation at fX = 5.0 MHz.
Table 9-12. Square Wave Output Range of 8-Bit Timer/Event Counter 81
TCL811
TCL810
Minimum Pulse Width
Maximum Pulse Width
Resolution
0
2
4/fX (1.6
s) [3.2 s]
2
12/fX (409.6
s) [819.2 s]
2
4/fX (1.6
s) [3.2 s]
0
1
2
8/fX (25.6
s) [51.2 s]
2
16/fX (6.55 ms) [13.1 ms]
2
8/fX (25.6
s) [51.2 s]
Remarks 1. fX: Main system clock oscillation frequency
2. The values in parentheses ( ) apply to operation at fX = 10.0 MHz. (expanded-specification products
only)
3. The values in brackets [ ] apply to operation at fX = 5.0 MHz.