The Enhanced PWM mode supports Auto-Shutdown mode and Auto-Restart mode.
Figure 1: Waveform showing the Auto-Shutdown/Auto-Restart
Auto-Shutdown will disable the PWM outputs when an external shutdown event occurs and places the PWM output pins into a predetermined state. This mode is used to help prevent the PWM from damaging the application. The auto-shutdown sources are selected using the CCPxAS<2:0> bits of the CCPxAS register. A shutdown event may be generated by:
- A logic ‘0’ on the INT pin
- A logic ‘1’ on a Comparator (Cx) output
A shutdown condition is indicated by the CCPxASE (Auto-Shutdown Event Status) bit of the CCPxAS register.
- If the bit is a ‘0’, the PWM pins are operating normally.
- If the bit is a ‘1’, the PWM outputs are in the shutdown state.
When a shutdown event occurs, two things happen:
1) The CCPxASE bit is set to ‘1’. The CCPxASE will remain set until cleared in firmware or an auto-restart occurs.
2) The enabled PWM pins are asynchronously placed in their shutdown states. The PWM output pins are grouped into pairs [PxA/PxC] and [PxB/PxD]. The state of each pin pair is determined by the PSSxAC and PSSxBD bits of the CCPxAS register. Each pin pair may be placed into one of three states:
- Drive logic ‘1’
- Drive logic ‘0’
- Tri-state (high-impedance)
In the Figure 1 waveform plot above, the Shut-Down occurs at the "Shutdown Event Occurs" label. This is caused by the Comparator Output going to a high state.
The Enhanced PWM can be configured to automatically restart the PWM signal once the auto-shutdown condition has been removed. Auto-restart is enabled by setting the PxRSEN bit in the PWMxCON register.
If auto-restart is enabled, the CCPxASE bit will remain set as long as the auto-shutdown condition is active.
When the auto-shutdown condition is removed, the CCPxASE bit will be cleared via hardware and normal operation will resume.
This can be seen in Figure 1 above where the "PWM Resumes" label is shown. The Auto-Restart actually occurs right after the CCPxASE is cleared but the PWM waveform cannot start until a full pulse can be released.