MCUXpresso SDK API Reference Manual  Rev. 0
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
eFlexPWM Peripheral and Driver Overview

Peripheral feature and how this peripheral works

The pulse width modulator (PWM) module contains 4 PWM submodules, each of which can set up to generate various switching patterns, including highly sophisticated waveforms. It can be used to control all known motor types and is ideal for controlling different Switched Mode Power Supplies (SMPS) topologies as well.

Features

Support fractional delay logic to support more resolution than a single IPBus clock period, it can be used to achieve fine resolution the rising and falling edges of the Pwm23_deadtime and Pwm45_deadtime, and fine resolution for the PwmX period. The fractional delay logic can only be used when the IPBus clock is running at 100 MHz.

Support output logic to do flexibility control about fault disabling, polarity/mask control, and output enable. It process the PWM output form fractional delay logic (Pwm23_fractional_delay, Pwm45_fractional_delay and PwmX_fractional_delay) and output the final PWM signal (PWM_A , PWM_B and PWM_X). It also process the compare trigger output from PWM generation logic.

     + Final PWM output signal under fault status (fault input signal mapping from fault protection channel) can be
       follow types:
         1. Output with low.
         2. Output with high.
         3. Output with tristated.

     + Final mux trigger output signal (PWM_MUX_TRIG0/1)can choose to use "VAL compare trigger signal" from VAL
       registers logic or "final PWM output". The "VAL compare trigger signal" based on the counter value matching
       the value in one or more of the VAL0-5 registers.
         + The VAL0, VAL2, and VAL4 matching can use to generate PWM_MUX_TRIG0, and VAL1, VAL3, and VAL5 matching
           can use to generate PWM_MUX_TRIG1.
         + VAL0-5 registers compare trigger signals can be enabled/disabled independent.
         + VAL0-5 registers compare trigger signals can be generator on every full compare cycle (every PWM period
           which count from INIT to VAL1) or on local reload opportunities (need wait one or more reload
           opportunities according to reload configure).

How this peripheral works

How this driver are designed to make this peripheral works

The PWM driver provides the structure pwm_config_t, which contain four submodule configure structure pointers and two fault protection channel configure structure pointers, only actually used submodule/fault channels need to assign a value to its structure pointer. This is want to save stack space. The channel configure structure pwm_sm_config_t which contain several sub-structures and other member to cover all feature of one PWM submodule. The PWM_Init() function takes the argument in type of pwm_config_t, and can complete the initialization of the PWM module. Since PWM is very flexible and has a very complex function configuration, use sub-structures to facilitate the understanding of the module and provide function APIs to take them as parameters. Base on the sub-structures and other behaviors of PWM submodule, the PWM driver can be divided into several function API groups.

How to use this driver

Typical Use Case

  1. Generate PWM_A/B output with different pulse width and enable fault disable for PWM_A output. In this typical use case, the PWM submodule will count the rising edges of the IP bus clock divider by 1. The PWM_A output will be u16PwmPulse/u16PwmPeriod duty cycle PWM, and PWM_B duty cycle be the half of PWM_A. The PWM_A output will be disabled when the fault pins 0 of the fault protection channel 0 is activated (active level be logic 0).
    * pwm_config_t sPwmConfig = {0};
    * pwm_sm_config_t sSubmoduleConfig;
    * uint16_t u16PwmPeriod, u16PwmPulse;
    * sPwmConfig.psPwmSubmoduleConfig[0] = &sSubmoduleConfig;
    * sPwmConfig.psFaultProtectionConfig[0] = &sFaultConfig;
    * PWM_GetSMDefaultConfig(&sSubmoduleConfig);
    * u16PwmPulse, (u16PwmPulse / 2));
    * PWM_Init(PWM, &sPwmConfig);
    *
  2. Generate a pair of center aligned complementary PWM (PWM_B is inverted PWM_A) signals (with dead time insert). In this typical use case, the PWM submodule 0 will count the rising edges of the IP bus clock divider by 1. The PWM_A output will be u16PwmPulse/u16PwmPeriod duty cycle PWM, and PWM_B be the inverted of PWM_A. The dead time can be inserted before the rising edge of PWM_A/B. The inserted value is in the unit of IP clock cycle and PWM_A/B can choose to insert different values.
    * pwm_config_t sPwmConfig = {0};
    * pwm_sm_config_t sSubmoduleConfig;
    * uint16_t u16PwmPeriod, u16PwmPulse, u16DeadTime;
    * sPwmConfig.psPwmSubmoduleConfig[0] = &sSubmoduleConfig;
    * PWM_GetSMDefaultConfig(&sSubmoduleConfig);
    * u16PwmPulse, u16PwmPulse);
    * sSubmoduleConfig.sDeadTimeConfig.sDeadTimeValue0.bitsIntegerCycles = u16DeadTime;
    * sSubmoduleConfig.sDeadTimeConfig.sDeadTimeValue1.bitsIntegerCycles = u16DeadTime;
    * PWM_Init(PWM, &sPwmConfig);
    *
  3. Generate phase shifted PWMs In this typical use case, the PWM submodule 0 will start count the rising edges of the IP bus clock divider by 1. Submodule 1 count on same clock with submodule 0. And the PWM_A output of submodules 1 be delayed from the output of submodule 0 with same PWM period and same PWM pulse width.
    * pwm_config_t sPwmConfig = {0};
    * pwm_sm_config_t sSubmoduleConfig0, sSubmoduleConfig1;
    * uint16_t u16PwmPeriod, u16PwmPulse, u16PhaseDelay;
    * sPwmConfig.psPwmSubmoduleConfig[0] = &sSubmoduleConfig0;
    * sPwmConfig.psPwmSubmoduleConfig[0] = &sSubmoduleConfig1;
    * PWM_GetSMDefaultConfig(&sSubmoduleConfig0);
    * PWM_GetSMDefaultConfig(&sSubmoduleConfig1);
    * u16PwmPulse, u16PwmPulse);
    * sSubmoduleConfig1.sCounterConfig.u16PhaseDelayValue = u16PhaseDelay;
    * PWM_Init(PWM, &sPwmConfig);
    *