
2-57
3802 GROUP USER’S MANUAL
APPLICATION
2.4 PWM
Fig. 2.4.7 Setting of related registers
[About PWM output]
1. Set the PWM function enable bit to “1” : The P56/PWM pin is used as the PWM pin.
“H” level pulse is output first.
2. Set the PWM function enable bit to “0” : The P56/PWM pin is used as the port P56.
Thus, when fixing the output level, make sure the following.
First, write an output value to bit 6 of the Port P5 register.
Then write “X1XXXXXX2” to the Port P5 direction register.
(X : This bit is not used in this application. Set it to “0” or “1.” It’s value can be disregarded.)
3. After data is set to the PWM prescaler and the PWM register, the PWM waveforms corresponding to new data
will be output from the next repetitive cycle.
1
PWM function enable bit : PWM enabled (Note)
PWMCON
PWM control register (Address : 2B16)
255 ! (n + 1)
Set “T”, PWM cycle
n = 1
PREPWM
PWM prescaler (Address : 2C16)
Note : The PWM output function is given priority
even when the corresponding bit to P56 pin
of Port P5 direction register is set to “0”
(input mode).
b7
b0
0
Count source selection bit : f(XIN)
b7
b0
n
[Equation]
T =
Set “t”, “H” level width of PWM
m = 100
PWM
PWM register (Address : 2D16)
b7
b0
m
[Equation]
t =
f(XIN)
T ! m
255
Fig. 2.4.8 PWM output
PWM output
Change PWM
output data
From the next repetitive cycle,
output modified data