40
AT89/83EB5114
4311C–8051–02/08
PWM Unit 0 (PWMU0) The PWM unit 0 allows to generate precise pulse width modulation with variable duty
cycle and frequency.
The PWMU0 consists on a dedicated 16 bits auto reload counter/timer which serves as
a time base for the generation of 3 independent PWM signals.
Its clock input can be programmed to count any one of the following signals:
Peripheral clock, CkIdle
Timer 0 overflow
External input on W0CI (P4.0)
The PWMU0 timer/counter shares several external I/O. These pins are listed below. If a
port is not used for the PWMU0, it can still be used for standard I/O.
PWMU0 Timer
The PWMU0 timer is a common 16 bits time base for all three modules (See
Figure 16).
The timer count source is determined from the W0CPS1 and W0CPS0 bits in the
W0MOD register (See
Table 26) and can be programmed to run at:
Peripheral clock, CkIdle
Timer 0 overflow
External input on W0CI (P1.2)
The output frequency depends on the timer source and also on the W0F Registers.
Indeed, the timer/counter counts from zero up to a value loaded via SW0F registers.
Each time the counter is higher or equal to the SW0F shadow registers value, W0C reg-
isters are automatically reloaded with zero. If the W0UP bit is set, the shadow SW0F
registers are reloaded with the contents of W0F registers when the W0C overtakes. This
Note:
If the PWMU0 is Off (W0R bit in W0CON not set), the contents of W0FH and W0FL are
automatically copied on the shadow registers SW0FH and SW0FL. This allows to charge
the correct comparison values in order to have the wanted frequency as soon as the
PWM is turned on.
PWMU0 Component
External I/O Pin
16-bit Counter
W0CI (P4.0)
16-bit Module 0
W0M0 (P3.0)
16-bit Module 1
W0M1 (P3.1)
16-bit Module 2
W0M2 (P3.3)