3.2.17 High-Resolution Pulse Width Modulation Controller (PWM)

The High-Resolution Pulse Width Modulation Controller (PWM) controls several channels independently. Each channel controls one square output waveform. Characteristics of the output waveform such as period, duty-cycle and polarity are configurable through the user interface. Each channel selects and uses one of the clocks provided by the clock generator.

The clock generator provides several clocks resulting from the division of the PWM macrocell master clock. Channels can be synchronized, to generate non overlapped waveforms. All channels integrate a double buffering system in order to prevent an unexpected output waveform while modifying the period or the duty-cycle.

Using The Library

This section describes the features and use of the High-Resolution Pulse-Width Modulation (PWM). This flexible module provides features to support many types of Motor Control (MC) and Power Control (PC) applications, including:

• AC-to-DC Converters

• DC-to-DC Converters

• AC and DC Motor Control: Brushed DC, BLDC, PMSM, ACIM, SRM, Stepper, etc.

• Inverters

• Battery Chargers

• Digital Lighting

• Power Factor Correction (PFC)

• Four Independent PWM Generators, each with Dual Outputs

• Operating modes: – Independent Edge PWM mode – Variable Phase PWM mode – Independent Edge PWM mode, Dual Output – Center-Aligned PWM mode – Double Update Center-Aligned PWM mode – Dual Edge Center-Aligned PWM mode

• Output modes: – Complementary – Independent – Push-Pull

• Dead-Time Generator

• Output Override for Fault Handling

• Flexible Period/Duty Cycle Updating Options

• PWM Control Inputs (PCI) for PWM Pin Overrides and External PWM Synchronization

• Advanced Triggering Options

Library Interface

High-Resolution Pulse Width Modulation Controller peripheral library provides the following interfaces:

Functions

NameDescription
PWM_InitializeInitializes PWM Peripheral with the given configuration
PWM_DeinitializeDeinitializes the PWM to its Power-On Reset (POR) state
PWM_GeneratorEnableEnables the specific PWM generator
PWM_GeneratorDisableDisables the specific PWM generator
PWM_ModeSetSets the operating mode for a specific PWM generator
PWM_OutputModeSetConfigures the output mode of a specific PWM generator
PWM_EnableEnables all PWM generators
PWM_DisableDisables all PWM generators
PWM_MasterPeriodSetSets the period value for the Master Time Base generator
PWM_MasterDutyCycleSetSets the PWM master duty cycle register
PWM_MasterPhaseSet Sets the phase value for the Master Time Base generator
PWM_PeriodSetSets the period for a specific PWM generator's Time Base
PWM_DutyCycleSetSets the duty cycle for a specific PWM generator
PWM_PhaseSelectSelects the PWM generator source for Phase
PWM_PhaseSetSets the phase value in count for the PWM generator specific Time Base
PWM_OverrideDataSetUpdates PWM override data bits with the requested value for a specific PWM generator selected by the argument PWM_GENERATOR
PWM_OverrideDataHighSetUpdates PWM override high data bit with the requested value for a specific PWM generator selected by the argument PWM_GENERATOR
PWM_OverrideDataLowSetUpdates PWM override low data bit with the requested value for a specific PWM generator selected by the argument PWM_GENERATOR
PWM_OverrideDataGetGets PWM override value for the PWM Generator selected by the argument PWM_GENERATOR
PWM_OverrideHighEnableEnables PWM override on PWMH output for specific PWM generator selected by the argument PWM_GENERATOR.
PWM_OverrideLowEnableEnables PWM override on PWML output for specific PWM generator selected by the argument PWM_GENERATOR
PWM_OverrideHighDisableDisables PWM override on PWMH output for specific PWM generator selected by the argument PWM_GENERATOR
PWM_OverrideLowDisableDisables PWM override on PWML output for specific PWM generator selected by the argument PWM_GENERATOR
PWM_DeadTimeLowSetUpdates PWM Deadtime low register with the requested value for a specific PWM generator selected by the argument PWM_GENERATOR
PWM_DeadTimeHighSetUpdates PWM Deadtime high register with the requested value for a specific PWM generator selected by the argument PWM_GENERATOR
PWM_DeadTimeSetUpdates PWM Deadtime low and high register with the requested value for a specific PWM generator selected by the argument PWM_GENERATOR
PWM_TriggerCompareValueSetSets the PWM trigger compare value in count for the PWM Generator selected by the argument PWM_GENERATOR
PWM_GeneratorInterruptEnableEnables interrupt requests for the PWM Generator selected by the argument PWM_GENERATOR
PWM_GeneratorInterruptDisableDisables interrupt requests for the PWM Generator selected by the argument PWM_GENERATOR
PWM_GeneratorEventStatusGetGets the PWM interrupt status for the PWM Generator selected by the argument PWM_GENERATOR
PWM_GeneratorEventStatusClearClears the PWM interrupt status for the PWM Generator selected by the argument PWM_GENERATOR
PWM_SoftwareUpdateRequestRequests to update the data registers for specific PWM generator selected by the argument PWM_GENERATOR
PWM_SoftwareUpdatePendingGets the status of the update request for specific PWM generator selected by the argument PWM_GENERATOR
PWM_TriggerACompareValueSetSets the Trigger A compare value in count for a specific PWM generator selected by the argument PWM_GENERATOR
PWM_TriggerBCompareValueSetSets the Trigger B compare value in count for a specific PWM generator selected by the argument PWM_GENERATOR
PWM_TriggerCCompareValueSetSets the Trigger C compare value in count for a specific PWM generator selected by the argument PWM_GENERATOR

Data types and constants

NameTypeDescription
PWM_GENERATOREnumDefines the PWM generators that are selected from the MCC Harmony User Interface for the PWM output controls
PWM_GENERATOR_INTERRUPTEnumDefines the PWM generator interrupts that are available for the module to use
PWM_TRIGGER_COMPAREEnum

Defines the PWM generator Trigger Compare registers that are available for the module to use

PWM_MODESEnumDefines the PWM generator operating modes that are available
PWM_OUTPUT_MODESEnumDefines the PWM generator output modes that are available
PWM_SOURCE_SELECTEnumDefines the PWM generator Master or Independent source selection
PWM_GENERATOR_EOC_EVENT_CALLBACKTypedefCallback function type for PWM generator End of Conversion (EOC) event
PWM_GENERATOR_EOC_EVENT_CALLBACK_OBJStructHolds the callback and context information for handling events on a specified PWM Generator