| NUC472_NUC442_BSP V3.03.003 The Board Support Package for NUC472/NUC442

Macros | Functions
EPWM Exported Functions
NUC472/NUC442 Device Driver » EPWM Driver » EPWM Exported Constants
Collaboration diagram for EPWM Exported Functions:

## Macros
#define | EPWM_ENABLE_COMPLEMENTARY_MODE(pwm)
| This macro enable complementary mode. More...
#define | EPWM_DISABLE_COMPLEMENTARY_MODE(pwm)
| This macro disable complementary mode, and enable independent mode. More...
#define | EPWM_ENABLE_GROUP_MODE(pwm)
| This macro enable group mode. More...
#define | EPWM_DISABLE_GROUP_MODE(pwm)
| This macro disable group mode. More...
#define | EPWM_ENABLE_SYNC_MODE(pwm)
| This macro enable synchronous mode. More...
#define | EPWM_DISABLE_SYNC_MODE(pwm)
| This macro disable synchronous mode, and enable independent mode. More...
#define | EPWM_ENABLE_OUTPUT_INVERTER(pwm, u32ChannelMask)
| This macro enable output inverter of specified channel(s) More...
#define | EPWM_MASK_OUTPUT(pwm, u32ChannelMask, u32LevelMask)
| This macro mask output output logic to high or low. More...
#define | EPWM_SET_DIVIDER(pwm, u32ChannelNum, u32Divider)
| This macro set the divider of the selected channel. More...
#define | EPWM_SET_CMR(pwm, u32ChannelNum, u32CMR)
| This macro set the duty of the selected channel. More...
#define | EPWM_SET_CNR(pwm, u32ChannelNum, u32CNR)
| This macro set the period of the selected channel. More...
#define | EPWM_SET_ALIGNED_TYPE(pwm, u32ChannelMask, u32AlignedType)
| This macro set the PWM aligned type. More...

## Functions
uint32_t | EPWM_ConfigOutputChannel (EPWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32Frequency, uint32_t u32DutyCycle)
| This function config PWM generator and get the nearest frequency in edge aligned auto-reload mode. More...
void | EPWM_Start (EPWM_T *pwm, uint32_t u32ChannelMask)
| This function start PWM module. More...
void | EPWM_Stop (EPWM_T *pwm, uint32_t u32ChannelMask)
| This function stop PWM module. More...
void | EPWM_ForceStop (EPWM_T *pwm, uint32_t u32ChannelMask)
| This function stop PWM generation immediately by clear channel enable bit. More...
void | EPWM_EnableFaultBrake (EPWM_T *pwm, uint32_t u32ChannelMask, uint32_t u32LevelMask, uint32_t u32BrakeSource)
| This function enable fault brake of selected channels. More...
void | EPWM_ClearFaultBrakeFlag (EPWM_T *pwm, uint32_t u32BrakeSource)
| This function clear fault brake flag. More...
void | EPWM_EnableOutput (EPWM_T *pwm, uint32_t u32ChannelMask)
| This function enables PWM output generation of selected channels. More...
void | EPWM_DisableOutput (EPWM_T *pwm, uint32_t u32ChannelMask)
| This function disables PWM output generation of selected channels. More...
void | EPWM_EnableDeadZone (EPWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32Duration)
| This function enable Dead zone of selected channel. More...
void | EPWM_DisableDeadZone (EPWM_T *pwm, uint32_t u32ChannelNum)
| This function disable Dead zone of selected channel. More...
void | EPWM_EnableDutyInt (EPWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32IntDutyType)
| This function enable duty interrupt of selected channel. More...
void | EPWM_DisableDutyInt (EPWM_T *pwm, uint32_t u32ChannelNum)
| This function disable duty interrupt of selected channel. More...
void | EPWM_ClearDutyIntFlag (EPWM_T *pwm, uint32_t u32ChannelNum)
| This function clears duty interrupt flag of selected channel. More...
uint32_t | EPWM_GetDutyIntFlag (EPWM_T *pwm, uint32_t u32ChannelNum)
| This function get duty interrupt flag of selected channel. More...
void | EPWM_EnableFaultBrakeInt (EPWM_T *pwm, uint32_t u32BrakeSource)
| This function enable fault brake interrupt. More...
void | EPWM_DisableFaultBrakeInt (EPWM_T *pwm, uint32_t u32BrakeSource)
| This function disable fault brake interrupt. More...
void | EPWM_ClearFaultBrakeIntFlag (EPWM_T *pwm, uint32_t u32BrakeSource)
| This function clear fault brake interrupt of selected source. More...
uint32_t | EPWM_GetFaultBrakeIntFlag (EPWM_T *pwm, uint32_t u32BrakeSource)
| This function get fault brake interrupt of selected source. More...
void | EPWM_EnablePeriodInt (EPWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32IntPeriodType)
| This function enable period interrupt of selected channel. More...
void | EPWM_DisablePeriodInt (EPWM_T *pwm, uint32_t u32ChannelNum)
| This function disable period interrupt of selected channel. More...
void | EPWM_ClearPeriodIntFlag (EPWM_T *pwm, uint32_t u32ChannelNum)
| This function clear period interrupt of selected channel. More...
uint32_t | EPWM_GetPeriodIntFlag (EPWM_T *pwm, uint32_t u32ChannelNum)
| This function get period interrupt of selected channel. More...

## Detailed Description

## Macro Definition Documentation

## ◆ EPWM_DISABLE_COMPLEMENTARY_MODE

#define EPWM_DISABLE_COMPLEMENTARY_MODE | ( |  | pwm | ) |

This macro disable complementary mode, and enable independent mode.

Parameters

  [in] | pwm | The base address of PWM module

Returns
  None

Definition at line 88 of file epwm.h.

## ◆ EPWM_DISABLE_GROUP_MODE

#define EPWM_DISABLE_GROUP_MODE | ( |  | pwm | ) |

This macro disable group mode.

Parameters

  [in] | pwm | The base address of PWM module

Returns
  None

Definition at line 104 of file epwm.h.

## ◆ EPWM_DISABLE_SYNC_MODE

#define EPWM_DISABLE_SYNC_MODE | ( |  | pwm | ) |

This macro disable synchronous mode, and enable independent mode.

Parameters

  [in] | pwm | The base address of PWM module

Returns
  None

Definition at line 120 of file epwm.h.

## ◆ EPWM_ENABLE_COMPLEMENTARY_MODE

#define EPWM_ENABLE_COMPLEMENTARY_MODE | ( |  | pwm | ) |

This macro enable complementary mode.

Parameters

  [in] | pwm | The base address of PWM module

Returns
  None

Definition at line 80 of file epwm.h.

## ◆ EPWM_ENABLE_GROUP_MODE

#define EPWM_ENABLE_GROUP_MODE | ( |  | pwm | ) |

This macro enable group mode.

Parameters

  [in] | pwm | The base address of PWM module

Returns
  None

Definition at line 96 of file epwm.h.

## ◆ EPWM_ENABLE_OUTPUT_INVERTER

#define EPWM_ENABLE_OUTPUT_INVERTER | ( |  | pwm,
|  |  | u32ChannelMask
| ) |  |

This macro enable output inverter of specified channel(s)

Parameters

  [in] | pwm | The base address of PWM module
  [in] | u32ChannelMask | Combination of enabled channels. Each bit corresponds to a channel Bit 0 represents channel 0, bit 1 represents channel 1...

Returns
  None

Definition at line 130 of file epwm.h.

## ◆ EPWM_ENABLE_SYNC_MODE

#define EPWM_ENABLE_SYNC_MODE | ( |  | pwm | ) |

This macro enable synchronous mode.

Parameters

  [in] | pwm | The base address of PWM module

Returns
  None

Definition at line 112 of file epwm.h.

## ◆ EPWM_MASK_OUTPUT

#define EPWM_MASK_OUTPUT | ( |  | pwm,
|  |  | u32ChannelMask,
|  |  | u32LevelMask
| ) |  |

This macro mask output output logic to high or low.

Parameters

  [in] | pwm | The base address of PWM module
  [in] | u32ChannelMask | Combination of enabled channels. Each bit corresponds to a channel Bit 0 represents channel 0, bit 1 represents channel 1...
  [in] | u32LevelMask | Output logic to high or low

Returns
  None

Definition at line 147 of file epwm.h.

## ◆ EPWM_SET_ALIGNED_TYPE

#define EPWM_SET_ALIGNED_TYPE | ( |  | pwm,
|  |  | u32ChannelMask,
|  |  | u32AlignedType
| ) |  |

This macro set the PWM aligned type.

Parameters

  [in] | pwm | The base address of PWM module
  [in] | u32ChannelMask | This parameter is not used
  [in] | u32AlignedType | PWM aligned type, valid values are: EPWM_EDGE_ALIGNED EPWM_CENTER_ALIGNED

Returns
  None

Definition at line 209 of file epwm.h.

## ◆ EPWM_SET_CMR

#define EPWM_SET_CMR | ( |  | pwm,
|  |  | u32ChannelNum,
|  |  | u32CMR
| ) |  |

This macro set the duty of the selected channel.

Parameters

  [in] | pwm | The base address of PWM module
  [in] | u32ChannelNum | PWM channel number. Valid values are between 0~5
  [in] | u32CMR | Duty of specified channel. Valid values are between 0~0xFFFF

Returns
  None

Note
  This new setting will take effect on next PWM period

Definition at line 177 of file epwm.h.

## ◆ EPWM_SET_CNR

#define EPWM_SET_CNR | ( |  | pwm,
|  |  | u32ChannelNum,
|  |  | u32CNR
| ) |  |

This macro set the period of the selected channel.

Parameters

  [in] | pwm | The base address of PWM module
  [in] | u32ChannelNum | PWM channel number. Valid values are between 0~5
  [in] | u32CNR | Period of specified channel. Valid values are between 0~0xFFFF

Returns
  None

Note
  This new setting will take effect on next PWM period
  PWM counter will stop if period length set to 0

Definition at line 193 of file epwm.h.

## ◆ EPWM_SET_DIVIDER

#define EPWM_SET_DIVIDER | ( |  | pwm,
|  |  | u32ChannelNum,
|  |  | u32Divider
| ) |  |

This macro set the divider of the selected channel.

Parameters

  [in] | pwm | The base address of PWM module
  [in] | u32ChannelNum | PWM channel number. Valid values are between 0~5
  [in] | u32Divider | Clock divider of specified channel. Valid values are EPWM_CLK_DIV_1 EPWM_CLK_DIV_2 EPWM_CLK_DIV_4 EPWM_CLK_DIV_16

Returns
  None

Definition at line 165 of file epwm.h.

## Function Documentation

## ◆ EPWM_ClearDutyIntFlag()

void EPWM_ClearDutyIntFlag | ( | EPWM_T * | pwm,
|  | uint32_t | u32ChannelNum
| ) |  |

This function clears duty interrupt flag of selected channel.

Parameters

  [in] | pwm | The base address of PWM module
  [in] | u32ChannelNum | PWM channel number. Valid values are between 0~5

Returns
  None

Definition at line 278 of file epwm.c.

## ◆ EPWM_ClearFaultBrakeFlag()

void EPWM_ClearFaultBrakeFlag | ( | EPWM_T * | pwm,
|  | uint32_t | u32BrakeSource
| ) |  |

This function clear fault brake flag.

Parameters

  [in] | pwm | The base address of PWM module
  [in] | u32BrakeSource | This parameter is not used

Returns
  None

Note
  After fault brake occurred, application must clear fault brake source before re-enable PWM output

Definition at line 174 of file epwm.c.

## ◆ EPWM_ClearFaultBrakeIntFlag()

void EPWM_ClearFaultBrakeIntFlag | ( | EPWM_T * | pwm,
|  | uint32_t | u32BrakeSource
| ) |  |

This function clear fault brake interrupt of selected source.

Parameters

  [in] | pwm | The base address of PWM module
  [in] | u32BrakeSource | Fault brake source, could be either EPWM_STATUS_BRKIF0_Msk, or EPWM_STATUS_BRKIF1_Msk

Returns
  None

Definition at line 329 of file epwm.c.

## ◆ EPWM_ClearPeriodIntFlag()

void EPWM_ClearPeriodIntFlag | ( | EPWM_T * | pwm,
|  | uint32_t | u32ChannelNum
| ) |  |

This function clear period interrupt of selected channel.

Parameters

  [in] | pwm | The base address of PWM module
  [in] | u32ChannelNum | PWM channel number. Valid values are between 0~5

Returns
  None

Definition at line 380 of file epwm.c.

## ◆ EPWM_ConfigOutputChannel()

uint32_t EPWM_ConfigOutputChannel | ( | EPWM_T * | pwm,
|  | uint32_t | u32ChannelNum,
|  | uint32_t | u32Frequency,
|  | uint32_t | u32DutyCycle
| ) |  |

This function config PWM generator and get the nearest frequency in edge aligned auto-reload mode.

Parameters

  [in] | pwm | The base address of PWM module
  [in] | u32ChannelNum | PWM channel number. Valid values are between 0~5
  [in] | u32Frequency | Target generator frequency
  [in] | u32DutyCycle | Target generator duty cycle percentage. Valid range are between 0 ~ 100. 10 means 10%, 20 means 20%...

Returns
  Nearest frequency clock in nano second

Definition at line 35 of file epwm.c.

## ◆ EPWM_DisableDeadZone()

void EPWM_DisableDeadZone | ( | EPWM_T * | pwm,
|  | uint32_t | u32ChannelNum
| ) |  |

This function disable Dead zone of selected channel.

Parameters

  [in] | pwm | The base address of PWM module
  [in] | u32ChannelNum | PWM channel number. Valid values are between 0~5

Returns
  None

Definition at line 234 of file epwm.c.

## ◆ EPWM_DisableDutyInt()

void EPWM_DisableDutyInt | ( | EPWM_T * | pwm,
|  | uint32_t | u32ChannelNum
| ) |  |

This function disable duty interrupt of selected channel.

Parameters

  [in] | pwm | The base address of PWM module
  [in] | u32ChannelNum | PWM channel number. Valid values are between 0~5

Returns
  None

Definition at line 265 of file epwm.c.

## ◆ EPWM_DisableFaultBrakeInt()

void EPWM_DisableFaultBrakeInt | ( | EPWM_T * | pwm,
|  | uint32_t | u32BrakeSource
| ) |  |

This function disable fault brake interrupt.

Parameters

  [in] | pwm | The base address of PWM module
  [in] | u32BrakeSource | This parameter is not used

Returns
  None

Definition at line 316 of file epwm.c.

## ◆ EPWM_DisableOutput()

void EPWM_DisableOutput | ( | EPWM_T * | pwm,
|  | uint32_t | u32ChannelMask
| ) |  |

This function disables PWM output generation of selected channels.

Parameters

  [in] | pwm | The base address of PWM module
  [in] | u32ChannelMask | Combination of enabled channels. Each bit corresponds to a channel Set bit 0 to 1 disables channel 0 output, set bit 1 to 1 disables channel 1 output...

Returns
  None

Definition at line 202 of file epwm.c.

## ◆ EPWM_DisablePeriodInt()

void EPWM_DisablePeriodInt | ( | EPWM_T * | pwm,
|  | uint32_t | u32ChannelNum
| ) |  |

This function disable period interrupt of selected channel.

Parameters

  [in] | pwm | The base address of PWM module
  [in] | u32ChannelNum | This parameter is not used

Returns
  None

Definition at line 369 of file epwm.c.

## ◆ EPWM_EnableDeadZone()

void EPWM_EnableDeadZone | ( | EPWM_T * | pwm,
|  | uint32_t | u32ChannelNum,
|  | uint32_t | u32Duration
| ) |  |

This function enable Dead zone of selected channel.

Parameters

  [in] | pwm | The base address of PWM module
  [in] | u32ChannelNum | PWM channel number. Valid values are between 0~5
  [in] | u32Duration | Dead Zone length in PWM clock count, valid values are between 0~0x7FF

Returns
  None

Definition at line 218 of file epwm.c.

## ◆ EPWM_EnableDutyInt()

void EPWM_EnableDutyInt | ( | EPWM_T * | pwm,
|  | uint32_t | u32ChannelNum,
|  | uint32_t | u32IntDutyType
| ) |  |

This function enable duty interrupt of selected channel.

Parameters

  [in] | pwm | The base address of PWM module
  [in] | u32ChannelNum | PWM channel number. Valid values are between 0~5
  [in] | u32IntDutyType | This parameter is not used

Returns
  None

Definition at line 249 of file epwm.c.

## ◆ EPWM_EnableFaultBrake()

void EPWM_EnableFaultBrake | ( | EPWM_T * | pwm,
|  | uint32_t | u32ChannelMask,
|  | uint32_t | u32LevelMask,
|  | uint32_t | u32BrakeSource
| ) |  |

This function enable fault brake of selected channels.

Parameters

  [in] | pwm | The base address of PWM module
  [in] | u32ChannelMask | This parameter is not used
  [in] | u32LevelMask | Output high or low while fault brake occurs, each bit represent the level of a channel while fault brake occurs. Bit 0 represents channel 0, bit 1 represents channel 1... , bit 5 represent channel 5
  [in] | u32BrakeSource | Fault brake source, could be one of following source EPWM_BRK0_BKP0 EPWM_BRK0_CPO0 EPWM_BRK0_CPO1 EPWM_BRK0_CPO2 EPWM_BRK1_LVDBKEN EPWM_BK1SEL_BKP1 EPWM_BK1SEL_CPO0 EPWM_BK1SEL_CPO1 EPWM_BK1SEL_CPO2

Returns
  None

Definition at line 152 of file epwm.c.

## ◆ EPWM_EnableFaultBrakeInt()

void EPWM_EnableFaultBrakeInt | ( | EPWM_T * | pwm,
|  | uint32_t | u32BrakeSource
| ) |  |

This function enable fault brake interrupt.

Parameters

  [in] | pwm | The base address of PWM module
  [in] | u32BrakeSource | This parameter is not used

Returns
  None

Definition at line 305 of file epwm.c.

## ◆ EPWM_EnableOutput()

void EPWM_EnableOutput | ( | EPWM_T * | pwm,
|  | uint32_t | u32ChannelMask
| ) |  |

This function enables PWM output generation of selected channels.

Parameters

  [in] | pwm | The base address of PWM module
  [in] | u32ChannelMask | Combination of enabled channels. Each bit corresponds to a channel. Set bit 0 to 1 enables channel 0 output, set bit 1 to 1 enables channel 1 output...

Returns
  None

Definition at line 187 of file epwm.c.

## ◆ EPWM_EnablePeriodInt()

void EPWM_EnablePeriodInt | ( | EPWM_T * | pwm,
|  | uint32_t | u32ChannelNum,
|  | uint32_t | u32IntPeriodType
| ) |  |

This function enable period interrupt of selected channel.

Parameters

  [in] | pwm | The base address of PWM module
  [in] | u32ChannelNum | This parameter is not used
  [in] | u32IntPeriodType | This parameter is not used

Returns
  None

Note
  All channels share the same period interrupt type setting.

Definition at line 357 of file epwm.c.

## ◆ EPWM_ForceStop()

void EPWM_ForceStop | ( | EPWM_T * | pwm,
|  | uint32_t | u32ChannelMask
| ) |  |

This function stop PWM generation immediately by clear channel enable bit.

Parameters

  [in] | pwm | The base address of PWM module
  [in] | u32ChannelMask | This parameter is not used

Note
  All channels share one counter

Returns
  None

Definition at line 128 of file epwm.c.

## ◆ EPWM_GetDutyIntFlag()

uint32_t EPWM_GetDutyIntFlag | ( | EPWM_T * | pwm,
|  | uint32_t | u32ChannelNum
| ) |  |

This function get duty interrupt flag of selected channel.

Parameters

  [in] | pwm | The base address of PWM module
  [in] | u32ChannelNum | PWM channel number. Valid values are between 0~5

Returns
  Duty interrupt flag of specified channel

Return values

  0 | Duty interrupt did not occurred
  1 | Duty interrupt occurred

Definition at line 294 of file epwm.c.

## ◆ EPWM_GetFaultBrakeIntFlag()

uint32_t EPWM_GetFaultBrakeIntFlag | ( | EPWM_T * | pwm,
|  | uint32_t | u32BrakeSource
| ) |  |

This function get fault brake interrupt of selected source.

Parameters

  [in] | pwm | The base address of PWM module
  [in] | u32BrakeSource | Fault brake source, could be either EPWM_STATUS_BRKIF0_Msk, or EPWM_STATUS_BRKIF1_Msk

Returns
  Fault brake interrupt flag of specified source

Return values

  0 | Fault brake interrupt did not occurred
  1 | Fault brake interrupt occurred

Definition at line 344 of file epwm.c.

## ◆ EPWM_GetPeriodIntFlag()

uint32_t EPWM_GetPeriodIntFlag | ( | EPWM_T * | pwm,
|  | uint32_t | u32ChannelNum
| ) |  |

This function get period interrupt of selected channel.

Parameters

  [in] | pwm | The base address of PWM module
  [in] | u32ChannelNum | PWM channel number. Valid values are between 0~5

Returns
  Period interrupt flag of specified channel

Return values

  0 | Period interrupt did not occurred
  1 | Period interrupt occurred

Definition at line 394 of file epwm.c.

## ◆ EPWM_Start()

void EPWM_Start | ( | EPWM_T * | pwm,
|  | uint32_t | u32ChannelMask
| ) |  |

This function start PWM module.

Parameters

  [in] | pwm | The base address of PWM module
  [in] | u32ChannelMask | This parameter is not used

Note
  All channels share one counter

Returns
  None

Definition at line 104 of file epwm.c.

## ◆ EPWM_Stop()

void EPWM_Stop | ( | EPWM_T * | pwm,
|  | uint32_t | u32ChannelMask
| ) |  |

This function stop PWM module.

Parameters

  [in] | pwm | The base address of PWM module
  [in] | u32ChannelMask | This parameter is not used

Note
  All channels share one counter

Returns
  None

Definition at line 116 of file epwm.c.