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

Content including 1) peripheral features, work logic and work method; 2) driver design logic and use method; 3) typical use case. More...

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

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);
    *