3 operation as square-wave output (timer 01 only) – NEC switch User Manual
Page 88
CHAPTER 6 8-BIT TIMER/EVENT COUNTERS 00 AND 01
User’s Manual U12978EJ3V0UD
88
6.4.3 Operation as square-wave output (timer 01 only)
The 8-bit timer/event counter can generate output square waves of arbitrary frequency at intervals specified by
the count value set to 8-bit compare register 01 (CR01) in advance.
To operate 8-bit timer/event counter 01 as square wave output, the following settings are required.
<1> Set P26 to output mode (PM26 = 0) and the output latch of P26 to 0.
<2> Disable operation of 8-bit timer counter 01 (TM01) by setting TCE01 (bit 7 of 8-bit timer mode control
register 01 (TMC01)) to 0.
<3> Set the count clock of 8-bit timer/event counter 01 (see Table 6-7) and enable output of TO01 by setting
TOE01 (bit 0 of TMC01) to 1
<4> Set count values to CR01.
<5> Enable operation of TM01 by setting TCE01 to 1.
When the count value of 8-bit timer counter 01 (TM01) matches the value set to CR01, the TO01/P26/INTP0/TI01
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 TM01 value is cleared to 0, TM01 resumes counting, and an interrupt request signal
(INTTM01 is generated).
Setting bit 7 of TMC01 (TCE01) to 0 clears the square-wave output to 0.
Table 6-7 lists the square wave output range, and Figure 6-9 shows timing of square wave output.
Caution
When the TMC01 count clock is set and the operation of TM01 is enabled simultaneously by an
8-bit memory manipulation instruction, an error of more than 1 clock may occur in 1 cycle after
the timer has been started. Therefore, be sure to follow the settings above when the 8-bit
timer/event counter is operating as square-wave output.
Table 6-7. Square-Wave Output Range of 8-Bit Timer/Event Counter 01
TCL011
TCL010
Minimum Pulse Width
Maximum Pulse Width
Resolution
0
0
2
4
/f
X
(2.67
µs)
2
12
/f
X
(682.7
µs)
2
4
/f
X
(2.67
µs)
0
1
2
8
/f
X
(42.7
µs)
2
16
/f
X
(10.9 ms)
2
8
/f
X
(42.7
µs)
Remarks 1. f
X
: System clock oscillation frequency
2. The parenthesized values apply to operation at f
X
= 6.0 MHz.