3.9.2 CWG with Multiple Modes

Complementary Waveform Generator with Multiple Modes

3.9.2.1 Introduction

The Complementary Waveform Generator (CWG) produces half-bridge, full-bridge, and steering of Pulse Width Modulation (PWM) waveforms. The CWG generates two output waveforms from the selected input source. It is backwards compatible with previous CCP functions.

3.9.2.2 Supported Device Families

PIC12/16F161xPIC12/16F184xPIC16F153xx
PIC16F171xxPIC16F180xxPIC16F181xx
PIC16F183xxPIC16F184xxPIC16F188xx
PIC16F191xxPIC18F-K40PIC18F-K42
PIC18F-K83PIC18F-Q10PIC18F-Q20
PIC18F-Q24PIC18F-Q40PIC18F-Q41
PIC18F-Q43PIC18F-Q71PIC18F-Q83
PIC18F-Q84

3.9.2.3 Required Header Files:


#include "mcc_generated_files/cwg/cwg[X].h"
Note: Replace [X] with the selected instance number of the CWG module.

3.9.2.4 Module Documentation

3.9.2.4.1 CWGx

This file contains the API prototypes for the CWGx driver.

Module description

This file contains the API prototypes for the CWGx driver.

Version: CWGx Driver Version 2.11.1
Functions
  • void CWGx_Initialize (void)

    Initializes the CWGx module. This is called only once before calling other CWGx APIs.

  • void CWGx_LoadRiseDeadbandCount (uint8_t dutyValue)

    Sets the duration of the dead-band interval on the rising edge of the input source signal.

  • void CWGx_LoadFallDeadbandCount (uint8_t dutyValue)

    Sets the duration of the dead-band interval on the falling edge of the input source signal.

  • void CWGx_LoadBufferEnable (void)

    Enables the CWGx module to load the buffers on the next rising or falling event of the input signal.

  • bool CWGx_IsModuleEnabled (void)

    Returns the status of the CWGx module.

  • void CWGx_AutoShutdownEventSet (void)

    Puts the CWG outputs into the Auto-Shutdown state.

  • void CWGx_AutoShutdownEventClear (void)

    Resumes the operation of the CWG when the Auto-Shutdown state is disabled.

Function Documentation

CWGx_AutoShutdownEventClear()

void CWGx_AutoShutdownEventClear (void )

Resumes the operation of the CWG when the Auto-Shutdown state is disabled.

Precondition:

CWGx_Initialize() and CWGx_AutoShutdownEventSet() are already called.

Parameters:
None.
Returns:

None.

CWGx_AutoShutdownEventSet()

void CWGx_AutoShutdownEventSet (void )

Puts the CWG outputs into the Auto-Shutdown state.

Precondition:

CWGx_Initialize() is already called.

Parameters:
None.
Returns:

None.

CWGx_Initialize()

void CWGx_Initialize (void )

Initializes the CWGx module. This is called only once before calling other CWGx APIs.

Parameters:
None.
Returns:

None.

CWGx_IsModuleEnabled()

bool CWGx_IsModuleEnabled (void )

Returns the status of the CWGx module.

Parameters:
None.
Return values:
True

- CWGx is enabled.

False

- CWGx is disabled.

CWGx_LoadBufferEnable()

void CWGx_LoadBufferEnable (void )

Enables the CWGx module to load the buffers on the next rising or falling event of the input signal.

Precondition:

CWGx_Initialize() is already called.

Parameters:
None.
Returns:

None.

CWGx_LoadFallDeadbandCount()

void CWGx_LoadFallDeadbandCount (uint8_t dutyValue)

Sets the duration of the dead-band interval on the falling edge of the input source signal.

Precondition:

CWGx_Initialize() is already called.

Parameters:
dutyValue

- Duty cycle value.

Returns:

None.

CWGx_LoadRiseDeadbandCount()

void CWGx_LoadRiseDeadbandCount (uint8_t dutyValue)

Sets the duration of the dead-band interval on the rising edge of the input source signal.

Precondition:

CWGx_Initialize() is already called.

Parameters:
dutyValue

- Duty cycle value.

Returns:

None.

3.9.2.5 File Documentation

3.9.2.5.1 source/cwgx.c File Reference

This file contains the API implementations for the CWGx driver.

#include <xc.h>
#include "../cwg1.h"
#include "../../system/interrupt.h"

Functions

Detailed Description

This file contains the API implementations for the CWGx driver.

CWG1 Generated Driver File.

Version: CWGx Driver Version 2.11.1

Function Documentation

__interrupt()

void __interrupt (irq(CWG1) , base(8) )

3.9.2.5.2 source/cwgx.h File Reference

#include <xc.h>
#include <stdint.h>
#include <stdbool.h>

Functions

  • void CWGx_Initialize (void)

    Initializes the CWGx module. This is called only once before calling other CWGx APIs.

  • void CWGx_LoadRiseDeadbandCount (uint8_t dutyValue)

    Sets the duration of the dead-band interval on the rising edge of the input source signal.

  • void CWGx_LoadFallDeadbandCount (uint8_t dutyValue)

    Sets the duration of the dead-band interval on the falling edge of the input source signal.

  • void CWGx_LoadBufferEnable (void)

    Enables the CWGx module to load the buffers on the next rising or falling event of the input signal.

  • bool CWGx_IsModuleEnabled (void)

    Returns the status of the CWGx module.

  • void CWGx_AutoShutdownEventSet (void)

    Puts the CWG outputs into the Auto-Shutdown state.

  • void CWGx_AutoShutdownEventClear (void)

    Resumes the operation of the CWG when the Auto-Shutdown state is disabled.

Detailed Description

CWG1 Generated Driver API Header File.