Complementary Waveform Generator Example

Last modified by Microchip on 2023/11/09 09:03

This page is a step-by-step example which uses the Complementary Waveform Generator (CWG).

This example uses the Numerically Controlled Oscillator (NCO) output signal (running at 50% duty cycle) as the input and the High-Frequency Internal Oscillator (HFINTOSC) as a clock.

This example also produces two complementary outputs and uses an external switch as the shutdown control, as shown in the accompanying block diagram below.

Numerically Controlled Oscillator (NCO) output signal example

CWG Example Setup

  1. The NCO is selected as the input for the CWG module.

NCO is selected as the input for the CWG module

Back to Top


2. The High Frequency Internal Oscillator is selected as the clock source.

High Frequency Internal Oscillator is selected as the clock source

Back to Top


3. The dead-band delays are set to 63-64 clock counts.

dead-band delays are set to 63-64 clock counts

Back to Top


4. The CWGFLT1 pin is enabled as a shutdown signal which is connected to a normally open momentary switch. When the switch is pressed, a low signal appears on the CWGFLT1 pin and triggers the shutdown.

 CWGFLT1 pin is enabled as a shutdown signal

Back to Top


5. Auto-restart is enabled and the shutdown bit is cleared to start in Run mode.

Auto-restart is enabled and the shutdown bit is cleared to start in run mode

Back to Top


6. Both outputs are set to drive to their respective inactive mode when the shutdown signal occurs.

outputs are set to drive to their respective inactive mode

Back to Top


7. The CWG outputs are connected to the I/O pins and the output polarity is set to normal mode.

CWG outputs are connected to the I/O pins

Back to Top


8. The CWG is then enabled. For reference, the NCO setup code is also shown that produces the input signal.

CWG is then enable

Back to Top

CWG Example Operation

The CWG example is running and the screen capture below shows the results.
The NCO signal can be seen at the top of the screen capture along with the CWGA and CWGB signals. You can also see the dead-band delays that are triggered by the edges of the NCO input signal.

CWG example is running and the screen capture below shows the resultsThe CWG is forced into shutdown mode.
When the momentary switch is pressed, the CWG outputs are driven to their inactive state showing the shutdown has occurred.

CWG is forced into shutdown mode

Back to Top