WB_PWMX - Initialization
Frozen Content
The following steps outline the basic procedure to initialize the WB_PWMX Controller ready for operation. You will need to re-initialize the Controller after each external reset.
- Write the resolution control bits (
mod1
andmod0
) in the Control register (PWCON.5 and PWCON.4) to set up the resolution you require. This should be done before writing the required pulse width to the PWMRG registers.
- Write the required value for the pulse width to the PWMRG register (upper 6 bits written to the PWMRGHI address and low byte written to the PWMRGLO address).
- Write the required low-order byte of the pre-scale value to the PWPLO register.
- Write the required high-order byte of the pre-scale value to the PWPHI register.
- Write the necessary value to the Control register (PWCON) to enable the Controller and interrupts. For example, to enable the controller and all interrupts, the following bits must be set:
pwen
(PWCON.0) – enable the Controllerpien
(PWCON.1) – global interrupt enableprie
(PWCON.2) – enable pre-scaler counter interruptpwie
(PWCON.3) – enable PWM counter interrupt.
- This would be performed using a read-modify-write operation, since you have already set the resolution mode bits in the Control register.