CHAPTER 7 TIMER/COUNTER FUNCTION
User’s Manual U13850EJ6V0UD
247
7.4.4 Operation as 8-bit PWM output
By setting the TMCn6 bit of 8-bit timer mode control register n (TMCn) to 1, the timer operates as a PWM output.
Pulses with the duty factor determined by the value set to 8-bit compare register n (CRn0) are output from TOn.
Set the width of the active level of the PWM pulse to CRn0. The active level can be selected by the TMCn1 bit in
TMCn.
The count clock can be selected by the TCLn0 to TCLn2 bits of timer clock selection register n0 (TCLn0) and by
the TCLn3 bit of timer clock selection register n1 (TCLn1).
The PWM output can be enabled and disabled by the TOEn bit of TMCn.
Caution
CRn0 can be rewritten only once in one cycle while in the PWM mode.
Remark
n = 2 to 5
(1) Basic operation of the PWM output
Setting method
(1) Set the port latch and port mode register n to 0.
(2) Set the active level width in 8-bit compare register n (CRn0).
(3) Select the count clock using timer clock selection register n0, n1 (TCLn0, TCLn1).
(4) Set the active level in TMCn1 bit of TMCn.
(5) If TCEn bit of TMCn is set to 1, counting starts. When counting stops, set TCEn to 0.
PWM output operation
(1) When counting starts, the PWM output (output from TOn) outputs the inactive level until an overflow
occurs.
(2) When the overflow occurs, the active level specified in step (1) in the setting method is output. The active
level is output until CRn0 and the count of 8-bit counter n (TMn) match.
(3) The PWM output after CRn0 and the count match is the inactive level until an overflow occurs again.
(4) Steps (2) and (3) repeat until counting stops.
(5) If counting is stopped by TCEn = 0, the PWM output goes to the inactive level.
Remark
n = 2 to 5
Содержание V850/SB1
Страница 2: ...User s Manual U13850EJ6V0UD 2 MEMO ...