32.13 Configuring the CWG

  1. Ensure that the TRIS control bits corresponding to CWG outputs are set so that all are configured as inputs, ensuring that the outputs are inactive during setup. External hardware must ensure that pin levels are held to safe levels.
  2. Clear the EN bit, if not already cleared.
  3. Configure the MODE bits to set the output operating mode.
  4. Configure the POLy bits to set the output polarities.
  5. Configure the ISM bits to select the data input source.
  6. If a Steering mode is selected, configure the STRy bits to select the desired output on the CWG outputs.
  7. Configure the LSBD and LSAC bits to select the Auto-Shutdown Output Override states (this is necessary even if not using auto-shutdown, because start-up will be from a Shutdown state).
  8. If auto-restart is desired, set the REN bit.
  9. If auto-shutdown is desired, configure the ASyE bits to select the shutdown source.
  10. Set the desired rising and falling dead-band times with the CWGxDBR and CWGxDBF registers.
  11. Select the clock source with the CS bit.
  12. Set the EN bit to enable the module.
  13. Clear the TRIS bits that correspond to the CWG outputs to set them as outputs.

If auto-restart is to be used, set the REN bit and the SHUTDOWN bit will be cleared automatically. Otherwise, clear the SHUTDOWN bit in software to start the CWG.