W78LE365/W78L365A
This gives a repetition frequency range of 123 Hz to 31.4 KHz ( fosc = 16 MHz). By loading the PWM
registers with either 00H or FFH, the PWM channels will output a constant HIGH or LOW level,
respectively. Since the 8-bit counter counts modulo 255, it can never actually reach the value of the
PWM registers when they are loaded with FFH.
When a compare register (PWM0, PWM1, PWM2, PWM3, PWM4) is loaded with a new value, the
associated output updated immediately. It does not have to wait until the end of the current counter
period. There is weakly pulled high on PWM output.
comparator
ENPWM0/1/2/3/4
PWM0OE
PWM0
PWM0
(P1.3)
f
Prescaler
PWMP
osc
1/2
8bit counter
PWM1
PWM1OE
PWM1
(P1.4)
comparator
comparator
PWM2OE
PWM3OE
PWM2
PWM2
(P1.5)
8bit counter
PWM3
(P1.6)
PWM3
comparator
comparator
8bit counter
PWM4
PWM4OE
PWM4
(P1.7)
FIGURE 1 PWM DIAGRAM
Please refer as below code.
mov pwmcon1, #00110011b ; enable pwm3, 2, 1, 0
mov pwmcon2, #00000101b ; enable pwm4
mov pwmp, #40h
jb p1.3, $
mov pwm0, #14h
jb p1.4, $
mov pwm1, #18h
; Fpwm = XT/(2*(1+pwmp)*255)
; duty cycle high/low = pwm0/(255-pmw0)
Publication Release Date: January 10, 2007
Revision A7
- 15 -