![NEC V850/SC1 User Manual Download Page 307](http://html.mh-extra.com/html/nec/v850-sc1/v850-sc1_user-manual_248178307.webp)
CHAPTER 8 TIMER/COUNTER FUNCTION
User’s Manual U15109EJ3V0UD
305
8.4.3 Operation as square-wave output
A square-wave with any frequency is output at the interval preset to 16-bit compare register n (CRn).
By setting bit 0 (TOEn0) of 16-bit timer mode control register n0 (TMCn0) to 1, the output status of TOn is inverted
at an interval specified by the count value preset to CRn. In this way, a square wave of any frequency (duty ratio =
50%) can be output.
Setting method
(1) Set the registers.
•
Set the port latch and port mode register to 0
•
TCLn0, TCLn1:
Selects the count clock
•
CRn:
Compare value
•
TMCn0:
Clear and start mode entered when TMn and CRn match
LVSn0
LVRn0
Setting state of timer output flip-flop
1
0
High level output
0
1
Low level output
Inversion of timer output flip-flop enabled
Timer output enabled
→
TOEn0 = 1
(2) When TCEn0 = 1 is set, the counter starts operating.
(3) If the values of TMn and CRn match, the timer output flip-flop inverts. Also, INTTMn is generated and
TMn is cleared to 0000H.
(4) The timer output flip-flop is then inverted at the same interval and a square wave is output from TOn.
Remark
n = 5, 6
Figure 8-34. Square-Wave Output Operation Timing
0000H
0000H
0001H 0002H
N
−
1
N
0001H 0002H
N
N
−
1
N
0000H
Count clock
CRn
TOn
TMn count value
Count start
Note
The initial value of TOn output can be set with bits 3 and 2 (LVSn0, LVRn0) of the TMCn0 register.
Remark
n = 5, 6