
CHAPTER 7 8-BIT TIMER/EVENT COUNTER 00
User’s Manual U11919EJ4V0UD
106
7.4.3 Operation as square wave output
8-bit timer/event counter 00 can generate a square wave output of arbitrary frequency at intervals specified by
the count value set to 8-bit compare register 00 (CR00) in advance.
To operate 8-bit timer/event counter 00 as a square wave output, the following settings are required.
<1> Set P50 to output mode (PM50 = 0).
<2> Set 0 to the output latch of P50.
<3> Disable the operation of 8-bit timer counter 00 (TM00) (TCE00 (bit 7 of 8-bit timer mode control register 00
(TMC00)) = 1).
<4> Set the count clock for 8-bit timer/event counter 00 and enable output of TO0 (TOE00 (bit 0 of TMC00) = 1).
<5> Set a count value in CR00.
<6> Enable the operation of TM00 (TCE00 = 1).
When the count value of 8-bit timer counter 00 (TM00) matches the value set in CR00, the TO0/P50/TI0 pin
output is inverted. Through application of this mechanism, square waves of any frequency can be output. As soon
as a match occurs, the TM00 value is cleared to 0 then TM00 resumes counting, generating an interrupt request
signal (INTTM0).
Setting bit 7 in TMC00 (TCE00) to 0 clears the square-wave output to 0.
Table 7-5 lists the square wave output range, and Figure 7-6 shows the timing of square wave output.
Cautions 1. Before rewriting CR00, stop the timer operation.
If CR00 is rewritten while the timer
operation is enabled, the match interrupt request signal may be generated immediately.
2. If setting the count clock in TMC00 and enabling the operation of TM00 are performed at the
same time with an 8-bit memory manipulation instruction, the error one cycle after the timer
has been started may exceed one clock. To use 8-bit timer/event counter 00 as a square
wave output, therefore, perform the setting in the above sequence.
Table 7-5. Square Wave Output Range of 8-Bit Timer/Event Counter 00
TCL001
TCL000
Minimum Pulse Width
Maximum Pulse Width
Resolution
00
1/fX (200 ns)
2
8/fX (51.2
s)
1/fX (200 ns)
01
2
5/fX (6.4
s)
2
13/fX (1.64 ms)
2
5/fX (6.4
s)
Remarks 1. fX: System clock oscillation frequency
2. The parenthesized values apply to operation at fX = 5.0 MHz.