CHAPTER 8 8-BIT TIMER/EVENT COUNTER 5
User’s Manual U16896EJ2V0UD
303
8.4.3 Square-wave output operation
A square wave with any frequency can be output at an interval determined by the value preset in the CR5n register.
By setting the TMC5n.TOE5n bit to 1, the output status of the TO5n pin is inverted at an interval determined by the
count value preset in the CR5n register. In this way, a square wave of any frequency can be output (duty = 50%) (n =
0, 1).
Setting method
<1> Set each register.
•
TCL5n register: Selects the count clock (t).
•
CR5n register:
Compare value (N)
•
TMC5n register: Stops count operation, selects the mode in which clear & start occurs on a match
between the TM5n register and CR5n register, sets initial value of timer output,
enables timer output F/F inversion operation, and enables timer output.
(TMC5n register = 00001011B or 00000111B)
•
For the alternate-function pin settings, refer to
Table 4-12 Settings When Port Pins Are Used for
Alternate Functions.
<2> When the TMC5n.TCE5n bit is set to 1, counting starts.
<3> When the values of the TM5n register and CR5n register match, the timer output F/F is inverted.
Moreover, the INTTM5n signal is generated and the TM5n register is cleared to 00H.
<4> Then, the timer output F/F is inverted during the same interval and a square wave is output from the TO5n
pin.
Frequency = 1/2t(N + 1): N = 00H to FFH
Caution Do not rewrite the value of the CR5n register during square-wave output.