| Nano103 BSP V3.01.002 The Board Support Package for Nano103 Series

Macros | Functions
PWM Exported Functions
NANO103 Device Driver » PWM Driver

## Macros
#define | PWM_ENABLE_COMPLEMENTARY_MODE(pwm)
| This macro enable complementary mode. More...
#define | PWM_DISABLE_COMPLEMENTARY_MODE(pwm)
| This macro disable complementary mode, and enable independent mode. More...
#define | PWM_ENABLE_OUTPUT_INVERTER(pwm, u32ChannelMask)
| This macro enable output inverter of specified channel(s) More...
#define | PWM_GET_CAPTURE_RISING_DATA(pwm, u32ChannelNum)
| This macro get captured rising data. More...
#define | PWM_GET_CAPTURE_FALLING_DATA(pwm, u32ChannelNum)
| This macro get captured falling data. More...
#define | PWM_MASK_OUTPUT(pwm, u32ChannelMask, u32LevelMask)
| This macro mask output logic to high or low. More...
#define | PWM_SET_PRESCALER(pwm, u32ChannelNum, u32Prescaler)
| This macro set the prescaler of the selected channel. More...
#define | PWM_SET_CMR(pwm, u32ChannelNum, u32CMR)
| This macro set the comparator of the selected channel. More...
#define | PWM_SET_CNR(pwm, u32ChannelNum, u32CNR)
| This macro set the period of the selected channel. More...
#define | PWM_SET_ALIGNED_TYPE(pwm, u32ChannelMask, u32AlignedType)
| This macro set the PWM aligned type. More...
#define | PWM_CLR_COUNTER(pwm, u32ChannelMask)
| Clear counter of specified channel(s) More...
#define | PWM_SET_OUTPUT_LEVEL(pwm, u32ChannelMask, u32ZeroLevel, u32CmpUpLevel, u32PeriodLevel, u32CmpDownLevel)
| Set output level at zero, compare up, period(center) and compare down of specified channel(s) More...
#define | PWM_TRIGGER_BRAKE(pwm, u32ChannelMask, u32BrakeType)
| Trigger brake event from specified channel(s) More...
#define | PWM_SET_DEADZONE_CLK_SRC(pwm, u32ChannelNum, u32AfterPrescaler)
| Set Dead zone clock source. More...

## Functions
uint32_t | PWM_ConfigCaptureChannel (PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32UnitTimeNsec, uint32_t u32CaptureEdge)
| Configure PWM capture and get the nearest unit time. More...
uint32_t | PWM_ConfigOutputChannel (PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32Frequency, uint32_t u32DutyCycle)
| This function Configure PWM generator and get the nearest frequency in edge aligned auto-reload mode. More...
void | PWM_Start (PWM_T *pwm, uint32_t u32ChannelMask)
| Start PWM module. More...
void | PWM_Stop (PWM_T *pwm, uint32_t u32ChannelMask)
| Stop PWM module. More...
void | PWM_ForceStop (PWM_T *pwm, uint32_t u32ChannelMask)
| Stop PWM generation immediately by clear channel enable bit. More...
void | PWM_EnableADCTrigger (PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32Condition)
| Enable selected channel to trigger ADC. More...
void | PWM_DisableADCTrigger (PWM_T *pwm, uint32_t u32ChannelNum)
| Disable selected channel to trigger ADC. More...
void | PWM_ClearADCTriggerFlag (PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32Condition)
| Clear selected channel trigger ADC flag. More...
uint32_t | PWM_GetADCTriggerFlag (PWM_T *pwm, uint32_t u32ChannelNum)
| Get selected channel trigger ADC flag. More...
void | PWM_EnableFaultBrake (PWM_T *pwm, uint32_t u32ChannelMask, uint32_t u32LevelMask, uint32_t u32BrakeSource)
| This function enable fault brake of selected channel(s) More...
void | PWM_EnableCapture (PWM_T *pwm, uint32_t u32ChannelMask)
| Enable capture of selected channel(s) More...
void | PWM_DisableCapture (PWM_T *pwm, uint32_t u32ChannelMask)
| Disable capture of selected channel(s) More...
void | PWM_EnableOutput (PWM_T *pwm, uint32_t u32ChannelMask)
| Enables PWM output generation of selected channel(s) More...
void | PWM_DisableOutput (PWM_T *pwm, uint32_t u32ChannelMask)
| Disables PWM output generation of selected channel(s) More...
void | PWM_EnableDeadZone (PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32Duration)
| Enable Dead zone of selected channel. More...
void | PWM_DisableDeadZone (PWM_T *pwm, uint32_t u32ChannelNum)
| Disable Dead zone of selected channel. More...
void | PWM_EnableCaptureInt (PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32Edge)
| Enable capture interrupt of selected channel. More...
void | PWM_DisableCaptureInt (PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32Edge)
| Disable capture interrupt of selected channel. More...
void | PWM_ClearCaptureIntFlag (PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32Edge)
| Clear capture interrupt of selected channel. More...
uint32_t | PWM_GetCaptureIntFlag (PWM_T *pwm, uint32_t u32ChannelNum)
| Get capture interrupt of selected channel. More...
void | PWM_EnableDutyInt (PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32IntDutyType)
| Enable duty interrupt of selected channel. More...
void | PWM_DisableDutyInt (PWM_T *pwm, uint32_t u32ChannelNum)
| Disable duty interrupt of selected channel. More...
void | PWM_ClearDutyIntFlag (PWM_T *pwm, uint32_t u32ChannelNum)
| Clear duty interrupt flag of selected channel. More...
uint32_t | PWM_GetDutyIntFlag (PWM_T *pwm, uint32_t u32ChannelNum)
| Get duty interrupt flag of selected channel. More...
void | PWM_EnableLoadMode (PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32LoadMode)
| Enable load mode of selected channel. More...
void | PWM_DisableLoadMode (PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32LoadMode)
| Disable load mode of selected channel. More...
void | PWM_EnableFaultBrakeInt (PWM_T *pwm, uint32_t u32BrakeSource)
| This function enable fault brake interrupt. More...
void | PWM_DisableFaultBrakeInt (PWM_T *pwm, uint32_t u32BrakeSource)
| This function disable fault brake interrupt. More...
void | PWM_ClearFaultBrakeIntFlag (PWM_T *pwm, uint32_t u32BrakeSource)
| This function clear fault brake interrupt of selected source. More...
uint32_t | PWM_GetFaultBrakeIntFlag (PWM_T *pwm, uint32_t u32BrakeSource)
| This function get fault brake interrupt flag of selected source. More...
void | PWM_EnablePeriodInt (PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32IntPeriodType)
| Enable period interrupt of selected channel. More...
void | PWM_DisablePeriodInt (PWM_T *pwm, uint32_t u32ChannelNum)
| Disable period interrupt of selected channel. More...
void | PWM_ClearPeriodIntFlag (PWM_T *pwm, uint32_t u32ChannelNum)
| Clear period interrupt of selected channel. More...
uint32_t | PWM_GetPeriodIntFlag (PWM_T *pwm, uint32_t u32ChannelNum)
| Get period interrupt of selected channel. More...
void | PWM_EnableZeroInt (PWM_T *pwm, uint32_t u32ChannelNum)
| Enable zero interrupt of selected channel. More...
void | PWM_DisableZeroInt (PWM_T *pwm, uint32_t u32ChannelNum)
| Disable zero interrupt of selected channel. More...
void | PWM_ClearZeroIntFlag (PWM_T *pwm, uint32_t u32ChannelNum)
| Clear zero interrupt of selected channel. More...
uint32_t | PWM_GetZeroIntFlag (PWM_T *pwm, uint32_t u32ChannelNum)
| Get zero interrupt of selected channel. More...
void | PWM_SetClockSource (PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32ClkSrcSel)
| Set PWM clock source. More...
void | PWM_EnableBrakeNoiseFilter (PWM_T *pwm, uint32_t u32BrakePinNum, uint32_t u32ClkCnt, uint32_t u32ClkDivSel)
| Enable PWM brake noise filter function. More...
void | PWM_DisableBrakeNoiseFilter (PWM_T *pwm, uint32_t u32BrakePinNum)
| Disable PWM brake noise filter function. More...
void | PWM_EnableBrakePinInverse (PWM_T *pwm, uint32_t u32BrakePinNum)
| Enable PWM brake pin inverse function. More...
void | PWM_DisableBrakePinInverse (PWM_T *pwm, uint32_t u32BrakePinNum)
| Disable PWM brake pin inverse function. More...
void | PWM_SetBrakePinSource (PWM_T *pwm, uint32_t u32BrakePinNum, uint32_t u32SelAnotherModule)
| Set PWM brake pin source. More...
uint32_t | PWM_GetWrapAroundFlag (PWM_T *pwm, uint32_t u32ChannelNum)
| Get the time-base counter reached its maximum value flag of selected channel. More...
void | PWM_ClearWrapAroundFlag (PWM_T *pwm, uint32_t u32ChannelNum)
| Clear the time-base counter reached its maximum value flag of selected channel. More...

## Detailed Description

## Macro Definition Documentation

## ◆ PWM_CLR_COUNTER

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

Clear counter of specified channel(s)

Parameters

  [in] | pwm | The pointer of the specified PWM module
  [in] | u32ChannelMask | Combination of enabled channels. Each bit corresponds to a channel. Every two channels share the same setting. Bit 0 represents channel 0, bit 1 represents channel 1...

Returns
  None

This macro is used to clear counter of specified channel(s).

Definition at line 278 of file pwm.h.

## ◆ PWM_DISABLE_COMPLEMENTARY_MODE

#define PWM_DISABLE_COMPLEMENTARY_MODE | ( |  | pwm | ) |

This macro disable complementary mode, and enable independent mode.

Parameters

  [in] | pwm | The pointer of the specified PWM module

Returns
  None

This macro is used to disable complementary mode of PWM module.

Definition at line 160 of file pwm.h.

## ◆ PWM_ENABLE_COMPLEMENTARY_MODE

#define PWM_ENABLE_COMPLEMENTARY_MODE | ( |  | pwm | ) |

This macro enable complementary mode.

Parameters

  [in] | pwm | The pointer of the specified PWM module

Returns
  None

This macro is used to enable complementary mode of PWM module.

Definition at line 151 of file pwm.h.

## ◆ PWM_ENABLE_OUTPUT_INVERTER

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

This macro enable output inverter of specified channel(s)

Parameters

  [in] | pwm | The pointer of the specified 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

This macro is used to enable output inverter of specified channel(s).

Definition at line 171 of file pwm.h.

## ◆ PWM_GET_CAPTURE_FALLING_DATA

#define PWM_GET_CAPTURE_FALLING_DATA | ( |  | pwm,
|  |  | u32ChannelNum
| ) |  |

This macro get captured falling data.

Parameters

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

Returns
  None

This macro is used to get captured falling data of specified channel.

Definition at line 191 of file pwm.h.

## ◆ PWM_GET_CAPTURE_RISING_DATA

#define PWM_GET_CAPTURE_RISING_DATA | ( |  | pwm,
|  |  | u32ChannelNum
| ) |  |

This macro get captured rising data.

Parameters

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

Returns
  None

This macro is used to get captured rising data of specified channel.

Definition at line 181 of file pwm.h.

## ◆ PWM_MASK_OUTPUT

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

This macro mask output logic to high or low.

Parameters

  [in] | pwm | The pointer of the specified 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

This macro is used to mask output logic to high or low of specified channel(s).

Note
  If u32ChannelMask parameter is 0, then mask function will be disabled.

Definition at line 204 of file pwm.h.

## ◆ PWM_SET_ALIGNED_TYPE

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

This macro set the PWM aligned type.

Parameters

  [in] | pwm | The pointer of the specified PWM module
  [in] | u32ChannelMask | Combination of enabled channels. Each bit corresponds to a channel. Every two channels share the same setting. Bit 0 represents channel 0, bit 1 represents channel 1...
  [in] | u32AlignedType | PWM aligned type, valid values are: PWM_EDGE_ALIGNED PWM_CENTER_ALIGNED

Returns
  None

This macro is used to set the PWM aligned type of specified channel(s).

Definition at line 260 of file pwm.h.

## ◆ PWM_SET_CMR

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

This macro set the comparator of the selected channel.

Parameters

  [in] | pwm | The pointer of the specified PWM module
  [in] | u32ChannelNum | PWM channel number. Valid values are between 0~5
  [in] | u32CMR | Comparator of specified channel. Valid values are between 0~0xFFFF

Returns
  None

This macro is used to set the comparator of specified channel.

Note
  This new setting will take effect on next PWM period.

Definition at line 233 of file pwm.h.

## ◆ PWM_SET_CNR

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

This macro set the period of the selected channel.

Parameters

  [in] | pwm | The pointer of the specified PWM module
  [in] | u32ChannelNum | PWM channel number. Valid values are between 0, 2, 4. Every two channels share the same setting.
  [in] | u32CNR | Period of specified channel. Valid values are between 0~0xFFFF

Returns
  None

This macro is used to set the period of specified channel.

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

Definition at line 246 of file pwm.h.

## ◆ PWM_SET_DEADZONE_CLK_SRC

#define PWM_SET_DEADZONE_CLK_SRC | ( |  | pwm,
|  |  | u32ChannelNum,
|  |  | u32AfterPrescaler
| ) |  |

Set Dead zone clock source.

Parameters

  [in] | pwm | The pointer of the specified PWM module
  [in] | u32ChannelNum | PWM channel number. Valid values are between 0~5
  [in] | u32AfterPrescaler | Dead zone clock source is from prescaler output. Valid values are TRUE (after prescaler) or FALSE (before prescaler).

Returns
  None

This macro is used to set Dead zone clock source. Every two channels share the same setting.

Note
  The write-protection function should be disabled before using this function.

Definition at line 353 of file pwm.h.

## ◆ PWM_SET_OUTPUT_LEVEL

#define PWM_SET_OUTPUT_LEVEL | ( |  | pwm,
|  |  | u32ChannelMask,
|  |  | u32ZeroLevel,
|  |  | u32CmpUpLevel,
|  |  | u32PeriodLevel,
|  |  | u32CmpDownLevel
| ) |  |

Set output level at zero, compare up, period(center) and compare down of specified channel(s)

Parameters

  [in] | pwm | The pointer of the specified 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] | u32ZeroLevel | output level at zero point, valid values are: PWM_OUTPUT_NOTHING PWM_OUTPUT_LOW PWM_OUTPUT_HIGH PWM_OUTPUT_TOGGLE
  [in] | u32CmpUpLevel | output level at compare up point, valid values are: PWM_OUTPUT_NOTHING PWM_OUTPUT_LOW PWM_OUTPUT_HIGH PWM_OUTPUT_TOGGLE
  [in] | u32PeriodLevel | output level at period(center) point, valid values are: PWM_OUTPUT_NOTHING PWM_OUTPUT_LOW PWM_OUTPUT_HIGH PWM_OUTPUT_TOGGLE
  [in] | u32CmpDownLevel | output level at compare down point, valid values are: PWM_OUTPUT_NOTHING PWM_OUTPUT_LOW PWM_OUTPUT_HIGH PWM_OUTPUT_TOGGLE

Returns
  None

This macro is used to Set output level at zero, compare up, period(center) and compare down of specified channel(s).

Definition at line 316 of file pwm.h.

## ◆ PWM_SET_PRESCALER

#define PWM_SET_PRESCALER | ( |  | pwm,
|  |  | u32ChannelNum,
|  |  | u32Prescaler
| ) |  |

This macro set the prescaler of the selected channel.

Parameters

  [in] | pwm | The pointer of the specified PWM module
  [in] | u32ChannelNum | PWM channel number. Valid values are between 0~5
  [in] | u32Prescaler | Clock prescaler of specified channel. Valid values are between 1 ~ 0xFFF

Returns
  None

This macro is used to set the prescaler of specified channel.

Note
  Every even channel N, and channel (N + 1) share a prescaler. So if channel 0 prescaler changed, channel 1 will also be affected.

Definition at line 221 of file pwm.h.

## ◆ PWM_TRIGGER_BRAKE

#define PWM_TRIGGER_BRAKE | ( |  | pwm,
|  |  | u32ChannelMask,
|  |  | u32BrakeType
| ) |  |

Trigger brake event from specified channel(s)

Parameters

  [in] | pwm | The pointer of the specified PWM module
  [in] | u32ChannelMask | Combination of enabled channels. Each bit corresponds to a channel Bit 0 represents channel 0, bit 1 represents channel 2 and bit 2 represents channel 4
  [in] | u32BrakeType | Type of brake trigger. It supports PWM_FB_EDGE and PWM_FB_LEVEL. PWM_FB_EDGE PWM_FB_LEVEL

Returns
  None

This macro is used to trigger brake event from specified channel(s).

Definition at line 341 of file pwm.h.

## Function Documentation

## ◆ PWM_ClearADCTriggerFlag()

void PWM_ClearADCTriggerFlag | ( | PWM_T * | pwm,
|  | uint32_t | u32ChannelNum,
|  | uint32_t | u32Condition
| ) |  |

Clear selected channel trigger ADC flag.

Parameters

  [in] | pwm | The pointer of the specified PWM module PWM0 : PWM Group 0
  [in] | u32ChannelNum | PWM channel number. Valid values are between 0~5
  [in] | u32Condition | This parameter is not used

Returns
  None

This function is used to clear selected channel trigger ADC flag.

Definition at line 279 of file pwm.c.

## ◆ PWM_ClearCaptureIntFlag()

void PWM_ClearCaptureIntFlag | ( | PWM_T * | pwm,
|  | uint32_t | u32ChannelNum,
|  | uint32_t | u32Edge
| ) |  |

Clear capture interrupt of selected channel.

Parameters

  [in] | pwm | The pointer of the specified PWM module PWM0 : PWM Group 0
  [in] | u32ChannelNum | PWM channel number. Valid values are between 0~5
  [in] | u32Edge | Rising or falling edge to latch counter. PWM_CAPTURE_INT_RISING_LATCH PWM_CAPTURE_INT_FALLING_LATCH

Returns
  None

This function is used to clear capture interrupt of selected channel.

Definition at line 509 of file pwm.c.

## ◆ PWM_ClearDutyIntFlag()

void PWM_ClearDutyIntFlag | ( | PWM_T * | pwm,
|  | uint32_t | u32ChannelNum
| ) |  |

Clear duty interrupt flag of selected channel.

Parameters

  [in] | pwm | The pointer of the specified PWM module PWM0 : PWM Group 0
  [in] | u32ChannelNum | PWM channel number. Valid values are between 0~5

Returns
  None

This function is used to clear duty interrupt flag of selected channel.

Definition at line 567 of file pwm.c.

## ◆ PWM_ClearFaultBrakeIntFlag()

void PWM_ClearFaultBrakeIntFlag | ( | PWM_T * | pwm,
|  | uint32_t | u32BrakeSource
| ) |  |

This function clear fault brake interrupt of selected source.

Parameters

  [in] | pwm | The pointer of the specified PWM module
  [in] | u32BrakeSource | Fault brake source. PWM_FB_EDGE PWM_FB_LEVEL

Returns
  None

This function is used to clear fault brake interrupt of selected source. The write-protection function should be disabled before using this function.

Definition at line 665 of file pwm.c.

## ◆ PWM_ClearPeriodIntFlag()

void PWM_ClearPeriodIntFlag | ( | PWM_T * | pwm,
|  | uint32_t | u32ChannelNum
| ) |  |

Clear period interrupt of selected channel.

Parameters

  [in] | pwm | The pointer of the specified PWM module PWM0 : PWM Group 0
  [in] | u32ChannelNum | PWM channel number. Valid values are between 0~5. Every two channels share the same setting.

Returns
  None

This function is used to clear period interrupt of selected channel.

Definition at line 723 of file pwm.c.

## ◆ PWM_ClearWrapAroundFlag()

void PWM_ClearWrapAroundFlag | ( | PWM_T * | pwm,
|  | uint32_t | u32ChannelNum
| ) |  |

Clear the time-base counter reached its maximum value flag of selected channel.

Parameters

  [in] | pwm | The pointer of the specified PWM module PWM0 : PWM Group 0
  [in] | u32ChannelNum | PWM channel number. Valid values are between 0~5. Every two channels share the same setting.

Returns
  None

This function is used to clear the time-base counter reached its maximum value flag of selected channel.

Definition at line 918 of file pwm.c.

## ◆ PWM_ClearZeroIntFlag()

void PWM_ClearZeroIntFlag | ( | PWM_T * | pwm,
|  | uint32_t | u32ChannelNum
| ) |  |

Clear zero interrupt of selected channel.

Parameters

  [in] | pwm | The pointer of the specified PWM module PWM0 : PWM Group 0
  [in] | u32ChannelNum | PWM channel number. Valid values are between 0~5. Every two channels share the same setting.

Returns
  None

This function is used to clear zero interrupt of selected channel.

Definition at line 777 of file pwm.c.

## ◆ PWM_ConfigCaptureChannel()

uint32_t PWM_ConfigCaptureChannel | ( | PWM_T * | pwm,
|  | uint32_t | u32ChannelNum,
|  | uint32_t | u32UnitTimeNsec,
|  | uint32_t | u32CaptureEdge
| ) |  |

Configure PWM capture and get the nearest unit time.

Parameters

  [in] | pwm | The pointer of the specified PWM module PWM0 : PWM Group 0
  [in] | u32ChannelNum | PWM channel number. Valid values are between 0~5
  [in] | u32UnitTimeNsec | The unit time of counter
  [in] | u32CaptureEdge | The condition to latch the counter. This parameter is not used

Returns
  The nearest unit time in nano second.

This function is used to Configure PWM capture and get the nearest unit time.

Definition at line 37 of file pwm.c.

## ◆ PWM_ConfigOutputChannel()

uint32_t PWM_ConfigOutputChannel | ( | PWM_T * | pwm,
|  | uint32_t | u32ChannelNum,
|  | uint32_t | u32Frequency,
|  | uint32_t | u32DutyCycle
| ) |  |

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

Parameters

  [in] | pwm | The pointer of the specified PWM module PWM0 : PWM Group 0
  [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

Note
  Since every two channels, (0 & 1), (2 & 3), shares a prescaler. Call this API to configure PWM frequency may affect existing frequency of other channel.

Definition at line 96 of file pwm.c.

## ◆ PWM_DisableADCTrigger()

void PWM_DisableADCTrigger | ( | PWM_T * | pwm,
|  | uint32_t | u32ChannelNum
| ) |  |

Disable selected channel to trigger ADC.

Parameters

  [in] | pwm | The pointer of the specified PWM module PWM0 : PWM Group 0
  [in] | u32ChannelNum | PWM channel number. Valid values are between 0~5

Returns
  None

This function is used to disable selected channel to trigger ADC.

Definition at line 258 of file pwm.c.

## ◆ PWM_DisableBrakeNoiseFilter()

void PWM_DisableBrakeNoiseFilter | ( | PWM_T * | pwm,
|  | uint32_t | u32BrakePinNum
| ) |  |

Disable PWM brake noise filter function.

Parameters

  [in] | pwm | The pointer of the specified PWM module PWM0 : PWM Group 0
  [in] | u32BrakePinNum | Brake pin selection. Valid values are 0 or 1.

Returns
  None

This function is used to disable PWM brake noise filter function.

Definition at line 850 of file pwm.c.

## ◆ PWM_DisableBrakePinInverse()

void PWM_DisableBrakePinInverse | ( | PWM_T * | pwm,
|  | uint32_t | u32BrakePinNum
| ) |  |

Disable PWM brake pin inverse function.

Parameters

  [in] | pwm | The pointer of the specified PWM module PWM0 : PWM Group 0
  [in] | u32BrakePinNum | Brake pin selection. Valid values are 0 or 1.

Returns
  None

This function is used to disable PWM brake pin inverse function.

Definition at line 876 of file pwm.c.

## ◆ PWM_DisableCapture()

void PWM_DisableCapture | ( | PWM_T * | pwm,
|  | uint32_t | u32ChannelMask
| ) |  |

Disable capture of selected channel(s)

Parameters

  [in] | pwm | The pointer of the specified PWM module PWM0 : PWM Group 0
  [in] | u32ChannelMask | Combination of enabled channels. Each bit corresponds to a channel. Bit 0 is channel 0, bit 1 is channel 1...

Returns
  None

This function is used to disable capture of selected channel(s).

Definition at line 399 of file pwm.c.

## ◆ PWM_DisableCaptureInt()

void PWM_DisableCaptureInt | ( | PWM_T * | pwm,
|  | uint32_t | u32ChannelNum,
|  | uint32_t | u32Edge
| ) |  |

Disable capture interrupt of selected channel.

Parameters

  [in] | pwm | The pointer of the specified PWM module PWM0 : PWM Group 0
  [in] | u32ChannelNum | PWM channel number. Valid values are between 0~5
  [in] | u32Edge | Rising or falling edge to latch counter. PWM_CAPTURE_INT_RISING_LATCH PWM_CAPTURE_INT_FALLING_LATCH

Returns
  None

This function is used to disable capture interrupt of selected channel.

Definition at line 493 of file pwm.c.

## ◆ PWM_DisableDeadZone()

void PWM_DisableDeadZone | ( | PWM_T * | pwm,
|  | uint32_t | u32ChannelNum
| ) |  |

Disable Dead zone of selected channel.

Parameters

  [in] | pwm | The pointer of the specified PWM module PWM0 : PWM Group 0
  [in] | u32ChannelNum | PWM channel number. Valid values are between 0~5

Returns
  None

This function is used to disable Dead zone of selected channel. The write-protection function should be disabled before using this function.

Definition at line 460 of file pwm.c.

## ◆ PWM_DisableDutyInt()

void PWM_DisableDutyInt | ( | PWM_T * | pwm,
|  | uint32_t | u32ChannelNum
| ) |  |

Disable duty interrupt of selected channel.

Parameters

  [in] | pwm | The pointer of the specified PWM module PWM0 : PWM Group 0
  [in] | u32ChannelNum | PWM channel number. Valid values are between 0~5

Returns
  None

This function is used to disable duty interrupt of selected channel.

Definition at line 554 of file pwm.c.

## ◆ PWM_DisableFaultBrakeInt()

void PWM_DisableFaultBrakeInt | ( | PWM_T * | pwm,
|  | uint32_t | u32BrakeSource
| ) |  |

This function disable fault brake interrupt.

Parameters

  [in] | pwm | The pointer of the specified PWM module
  [in] | u32BrakeSource | Fault brake source. PWM_FB_EDGE PWM_FB_LEVEL

Returns
  None

This function is used to disable fault brake interrupt. The write-protection function should be disabled before using this function.

Note
  Every two channels share the same setting.

Definition at line 648 of file pwm.c.

## ◆ PWM_DisableLoadMode()

void PWM_DisableLoadMode | ( | PWM_T * | pwm,
|  | uint32_t | u32ChannelNum,
|  | uint32_t | u32LoadMode
| ) |  |

Disable load mode of selected channel.

Parameters

  [in] | pwm | The pointer of the specified PWM module PWM0 : PWM Group 0
  [in] | u32ChannelNum | PWM channel number. Valid values are between 0~5
  [in] | u32LoadMode | PWM counter loading mode. PWM_LOAD_MODE_IMMEDIATE PWM_LOAD_MODE_CENTER

Returns
  None

This function is used to disable load mode of selected channel.

Definition at line 614 of file pwm.c.

## ◆ PWM_DisableOutput()

void PWM_DisableOutput | ( | PWM_T * | pwm,
|  | uint32_t | u32ChannelMask
| ) |  |

Disables PWM output generation of selected channel(s)

Parameters

  [in] | pwm | The pointer of the specified PWM module PWM0 : PWM Group 0
  [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

This function is used to disable PWM output generation of selected channel(s).

Definition at line 428 of file pwm.c.

## ◆ PWM_DisablePeriodInt()

void PWM_DisablePeriodInt | ( | PWM_T * | pwm,
|  | uint32_t | u32ChannelNum
| ) |  |

Disable period interrupt of selected channel.

Parameters

  [in] | pwm | The pointer of the specified PWM module PWM0 : PWM Group 0
  [in] | u32ChannelNum | PWM channel number. Valid values are between 0~5. Every two channels share the same setting.

Returns
  None

This function is used to disable period interrupt of selected channel.

Definition at line 710 of file pwm.c.

## ◆ PWM_DisableZeroInt()

void PWM_DisableZeroInt | ( | PWM_T * | pwm,
|  | uint32_t | u32ChannelNum
| ) |  |

Disable zero interrupt of selected channel.

Parameters

  [in] | pwm | The pointer of the specified PWM module PWM0 : PWM Group 0
  [in] | u32ChannelNum | PWM channel number. Valid values are between 0~5. Every two channels share the same setting.

Returns
  None

This function is used to disable zero interrupt of selected channel.

Definition at line 764 of file pwm.c.

## ◆ PWM_EnableADCTrigger()

void PWM_EnableADCTrigger | ( | PWM_T * | pwm,
|  | uint32_t | u32ChannelNum,
|  | uint32_t | u32Condition
| ) |  |

Enable selected channel to trigger ADC.

Parameters

  [in] | pwm | The pointer of the specified PWM module PWM0 : PWM Group 0
  [in] | u32ChannelNum | PWM channel number. Valid values are between 0~5
  [in] | u32Condition | The condition to trigger ADC. Combination of following conditions: PWM_TRIGGER_ADC_EVEN_ZERO_POINT PWM_TRIGGER_ADC_EVEN_PERIOD_POINT PWM_TRIGGER_ADC_EVEN_ZERO_OR_PERIOD_POINT PWM_TRIGGER_ADC_EVEN_COMPARE_UP_COUNT_POINT PWM_TRIGGER_ADC_EVEN_COMPARE_DOWN_COUNT_POINT PWM_TRIGGER_ADC_ODD_COMPARE_UP_COUNT_POINT PWM_TRIGGER_ADC_ODD_COMPARE_DOWN_COUNT_POINT

Returns
  None

This function is used to enable selected channel to trigger ADC.

Definition at line 236 of file pwm.c.

## ◆ PWM_EnableBrakeNoiseFilter()

void PWM_EnableBrakeNoiseFilter | ( | PWM_T * | pwm,
|  | uint32_t | u32BrakePinNum,
|  | uint32_t | u32ClkCnt,
|  | uint32_t | u32ClkDivSel
| ) |  |

Enable PWM brake noise filter function.

Parameters

  [in] | pwm | The pointer of the specified PWM module PWM0 : PWM Group 0
  [in] | u32BrakePinNum | Brake pin selection. Valid values are 0 or 1.
  [in] | u32ClkCnt | SYNC Edge Detector Filter Count. This controls the counter number of edge detector
  [in] | u32ClkDivSel | SYNC Edge Detector Filter Clock Selection. PWM_NF_CLK_DIV_1 PWM_NF_CLK_DIV_2 PWM_NF_CLK_DIV_4 PWM_NF_CLK_DIV_8 PWM_NF_CLK_DIV_16 PWM_NF_CLK_DIV_32 PWM_NF_CLK_DIV_64 PWM_NF_CLK_DIV_128

Returns
  None

This function is used to enable PWM brake noise filter function.

Definition at line 836 of file pwm.c.

## ◆ PWM_EnableBrakePinInverse()

void PWM_EnableBrakePinInverse | ( | PWM_T * | pwm,
|  | uint32_t | u32BrakePinNum
| ) |  |

Enable PWM brake pin inverse function.

Parameters

  [in] | pwm | The pointer of the specified PWM module PWM0 : PWM Group 0
  [in] | u32BrakePinNum | Brake pin selection. Valid values are 0 or 1.

Returns
  None

This function is used to enable PWM brake pin inverse function.

Definition at line 863 of file pwm.c.

## ◆ PWM_EnableCapture()

void PWM_EnableCapture | ( | PWM_T * | pwm,
|  | uint32_t | u32ChannelMask
| ) |  |

Enable capture of selected channel(s)

Parameters

  [in] | pwm | The pointer of the specified PWM module PWM0 : PWM Group 0
  [in] | u32ChannelMask | Combination of enabled channels. Each bit corresponds to a channel. Bit 0 is channel 0, bit 1 is channel 1...

Returns
  None

This function is used to enable capture of selected channel(s).

Definition at line 384 of file pwm.c.

## ◆ PWM_EnableCaptureInt()

void PWM_EnableCaptureInt | ( | PWM_T * | pwm,
|  | uint32_t | u32ChannelNum,
|  | uint32_t | u32Edge
| ) |  |

Enable capture interrupt of selected channel.

Parameters

  [in] | pwm | The pointer of the specified PWM module PWM0 : PWM Group 0
  [in] | u32ChannelNum | PWM channel number. Valid values are between 0~5
  [in] | u32Edge | Rising or falling edge to latch counter. PWM_CAPTURE_INT_RISING_LATCH PWM_CAPTURE_INT_FALLING_LATCH

Returns
  None

This function is used to enable capture interrupt of selected channel.

Definition at line 477 of file pwm.c.

## ◆ PWM_EnableDeadZone()

void PWM_EnableDeadZone | ( | PWM_T * | pwm,
|  | uint32_t | u32ChannelNum,
|  | uint32_t | u32Duration
| ) |  |

Enable Dead zone of selected channel.

Parameters

  [in] | pwm | The pointer of the specified PWM module PWM0 : PWM Group 0
  [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~0xFFF, but 0 means there is no Dead zone.

Returns
  None

This function is used to enable Dead zone of selected channel. The write-protection function should be disabled before using this function.

Note
  Every two channels share the same setting.

Definition at line 444 of file pwm.c.

## ◆ PWM_EnableDutyInt()

void PWM_EnableDutyInt | ( | PWM_T * | pwm,
|  | uint32_t | u32ChannelNum,
|  | uint32_t | u32IntDutyType
| ) |  |

Enable duty interrupt of selected channel.

Parameters

  [in] | pwm | The pointer of the specified PWM module PWM0 : PWM Group 0
  [in] | u32ChannelNum | PWM channel number. Valid values are between 0~5
  [in] | u32IntDutyType | Duty interrupt type, could be either PWM_DUTY_INT_DOWN_COUNT_MATCH_CMP PWM_DUTY_INT_UP_COUNT_MATCH_CMP

Returns
  None

This function is used to enable duty interrupt of selected channel.

Definition at line 541 of file pwm.c.

## ◆ PWM_EnableFaultBrake()

void PWM_EnableFaultBrake | ( | PWM_T * | pwm,
|  | uint32_t | u32ChannelMask,
|  | uint32_t | u32LevelMask,
|  | uint32_t | u32BrakeSource
| ) |  |

This function enable fault brake of selected channel(s)

Parameters

  [in] | pwm | The pointer of the specified PWM module PWM0 : PWM Group 0
  [in] | u32ChannelMask | Combination of enabled channels. Each bit corresponds to a channel.
  [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...
  [in] | u32BrakeSource | Fault brake source, could be one of following source PWM_FB_EDGE_BKP0 PWM_FB_EDGE_BKP1 PWM_FB_EDGE_SYS_BOD PWM_FB_EDGE_SYS_COR PWM_FB_LEVEL_BKP0 PWM_FB_LEVEL_BKP1 PWM_FB_LEVEL_SYS_BOD PWM_FB_LEVEL_SYS_COR

Returns
  None

This function is used to enable fault brake of selected channel(s). The write-protection function should be disabled before using this function.

Definition at line 318 of file pwm.c.

## ◆ PWM_EnableFaultBrakeInt()

void PWM_EnableFaultBrakeInt | ( | PWM_T * | pwm,
|  | uint32_t | u32BrakeSource
| ) |  |

This function enable fault brake interrupt.

Parameters

  [in] | pwm | The pointer of the specified PWM module
  [in] | u32BrakeSource | Fault brake source. PWM_FB_EDGE PWM_FB_LEVEL

Returns
  None

This function is used to enable fault brake interrupt. The write-protection function should be disabled before using this function.

Note
  Every two channels share the same setting.

Definition at line 630 of file pwm.c.

## ◆ PWM_EnableLoadMode()

void PWM_EnableLoadMode | ( | PWM_T * | pwm,
|  | uint32_t | u32ChannelNum,
|  | uint32_t | u32LoadMode
| ) |  |

Enable load mode of selected channel.

Parameters

  [in] | pwm | The pointer of the specified PWM module PWM0 : PWM Group 0
  [in] | u32ChannelNum | PWM channel number. Valid values are between 0~5
  [in] | u32LoadMode | PWM counter loading mode. PWM_LOAD_MODE_IMMEDIATE PWM_LOAD_MODE_CENTER

Returns
  None

This function is used to enable load mode of selected channel.

Definition at line 598 of file pwm.c.

## ◆ PWM_EnableOutput()

void PWM_EnableOutput | ( | PWM_T * | pwm,
|  | uint32_t | u32ChannelMask
| ) |  |

Enables PWM output generation of selected channel(s)

Parameters

  [in] | pwm | The pointer of the specified PWM module PWM0 : PWM Group 0
  [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

This function is used to enable PWM output generation of selected channel(s).

Definition at line 414 of file pwm.c.

## ◆ PWM_EnablePeriodInt()

void PWM_EnablePeriodInt | ( | PWM_T * | pwm,
|  | uint32_t | u32ChannelNum,
|  | uint32_t | u32IntPeriodType
| ) |  |

Enable period interrupt of selected channel.

Parameters

  [in] | pwm | The pointer of the specified PWM module PWM0 : PWM Group 0
  [in] | u32ChannelNum | PWM channel number. Valid values are between 0~5. Every two channels share the same setting.
  [in] | u32IntPeriodType | Period interrupt type. This parameter is not used.

Returns
  None

This function is used to enable period interrupt of selected channel.

Definition at line 697 of file pwm.c.

## ◆ PWM_EnableZeroInt()

void PWM_EnableZeroInt | ( | PWM_T * | pwm,
|  | uint32_t | u32ChannelNum
| ) |  |

Enable zero interrupt of selected channel.

Parameters

  [in] | pwm | The pointer of the specified PWM module PWM0 : PWM Group 0
  [in] | u32ChannelNum | PWM channel number. Valid values are between 0~5. Every two channels share the same setting.

Returns
  None

This function is used to enable zero interrupt of selected channel.

Definition at line 751 of file pwm.c.

## ◆ PWM_ForceStop()

void PWM_ForceStop | ( | PWM_T * | pwm,
|  | uint32_t | u32ChannelMask
| ) |  |

Stop PWM generation immediately by clear channel enable bit.

Parameters

  [in] | pwm | The pointer of the specified PWM module PWM0 : PWM Group 0
  [in] | u32ChannelMask | Combination of enabled channels. Each bit corresponds to a channel. Bit 0 is channel 0, bit 1 is channel 1...

Returns
  None

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

Definition at line 208 of file pwm.c.

## ◆ PWM_GetADCTriggerFlag()

uint32_t PWM_GetADCTriggerFlag | ( | PWM_T * | pwm,
|  | uint32_t | u32ChannelNum
| ) |  |

Get selected channel trigger ADC flag.

Parameters

  [in] | pwm | The pointer of the specified PWM module PWM0 : PWM Group 0
  [in] | u32ChannelNum | PWM channel number. Valid values are between 0~5

Return values

  0 | The specified channel trigger ADC to start of conversion flag is not set
  1 | The specified channel trigger ADC to start of conversion flag is set

This function is used to get PWM trigger ADC to start of conversion flag for specified channel.

Definition at line 293 of file pwm.c.

## ◆ PWM_GetCaptureIntFlag()

uint32_t PWM_GetCaptureIntFlag | ( | PWM_T * | pwm,
|  | uint32_t | u32ChannelNum
| ) |  |

Get capture interrupt of selected channel.

Parameters

  [in] | pwm | The pointer of the specified PWM module PWM0 : PWM Group 0
  [in] | u32ChannelNum | PWM channel number. Valid values are between 0~5

Return values

  0 | No capture interrupt
  1 | Rising edge latch interrupt
  2 | Falling edge latch interrupt
  3 | Rising and falling latch interrupt

This function is used to get capture interrupt of selected channel.

Definition at line 525 of file pwm.c.

## ◆ PWM_GetDutyIntFlag()

uint32_t PWM_GetDutyIntFlag | ( | PWM_T * | pwm,
|  | uint32_t | u32ChannelNum
| ) |  |

Get duty interrupt flag of selected channel.

Parameters

  [in] | pwm | The pointer of the specified PWM module PWM0 : PWM Group 0
  [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 occur
  1 | Duty interrupt occurred

This function is used to get duty interrupt flag of selected channel.

Definition at line 582 of file pwm.c.

## ◆ PWM_GetFaultBrakeIntFlag()

uint32_t PWM_GetFaultBrakeIntFlag | ( | PWM_T * | pwm,
|  | uint32_t | u32BrakeSource
| ) |  |

This function get fault brake interrupt flag of selected source.

Parameters

  [in] | pwm | The pointer of the specified PWM module
  [in] | u32BrakeSource | Fault brake source, could be either PWM_FB_EDGE PWM_FB_LEVEL

Returns
  Fault brake interrupt flag of specified source

Return values

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

This function is used to get fault brake interrupt flag of selected source.

Definition at line 683 of file pwm.c.

## ◆ PWM_GetPeriodIntFlag()

uint32_t PWM_GetPeriodIntFlag | ( | PWM_T * | pwm,
|  | uint32_t | u32ChannelNum
| ) |  |

Get period interrupt of selected channel.

Parameters

  [in] | pwm | The pointer of the specified PWM module PWM0 : PWM Group 0
  [in] | u32ChannelNum | PWM channel number. Valid values are between 0~5. Every two channels share the same setting.

Returns
  Period interrupt flag of specified channel

Return values

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

This function is used to get period interrupt of selected channel.

Definition at line 738 of file pwm.c.

## ◆ PWM_GetWrapAroundFlag()

uint32_t PWM_GetWrapAroundFlag | ( | PWM_T * | pwm,
|  | uint32_t | u32ChannelNum
| ) |  |

Get the time-base counter reached its maximum value flag of selected channel.

Parameters

  [in] | pwm | The pointer of the specified PWM module PWM0 : PWM Group 0
  [in] | u32ChannelNum | PWM channel number. Valid values are between 0~5. Every two channels share the same setting.

Returns
  Count to max interrupt flag of specified channel

Return values

  0 | Count to max interrupt did not occur
  1 | Count to max interrupt occurred

This function is used to get the time-base counter reached its maximum value flag of selected channel.

Definition at line 905 of file pwm.c.

## ◆ PWM_GetZeroIntFlag()

uint32_t PWM_GetZeroIntFlag | ( | PWM_T * | pwm,
|  | uint32_t | u32ChannelNum
| ) |  |

Get zero interrupt of selected channel.

Parameters

  [in] | pwm | The pointer of the specified PWM module PWM0 : PWM Group 0
  [in] | u32ChannelNum | PWM channel number. Valid values are between 0~5. Every two channels share the same setting.

Returns
  zero interrupt flag of specified channel

Return values

  0 | zero interrupt did not occur
  1 | zero interrupt occurred

This function is used to get zero interrupt of selected channel.

Definition at line 792 of file pwm.c.

## ◆ PWM_SetBrakePinSource()

void PWM_SetBrakePinSource | ( | PWM_T * | pwm,
|  | uint32_t | u32BrakePinNum,
|  | uint32_t | u32SelAnotherModule
| ) |  |

Set PWM brake pin source.

Parameters

  [in] | pwm | The pointer of the specified PWM module PWM0 : PWM Group 0
  [in] | u32BrakePinNum | Brake pin selection. Valid values are 0 or 1.
  [in] | u32SelAnotherModule | Select to another module. Valid values are TRUE or FALSE.

Returns
  None

This function is used to set PWM brake pin source.

Definition at line 890 of file pwm.c.

## ◆ PWM_SetClockSource()

void PWM_SetClockSource | ( | PWM_T * | pwm,
|  | uint32_t | u32ChannelNum,
|  | uint32_t | u32ClkSrcSel
| ) |  |

Set PWM clock source.

Parameters

  [in] | pwm | The pointer of the specified PWM module PWM0 : PWM Group 0
  [in] | u32ChannelNum | PWM channel number. Valid values are between 0~5
  [in] | u32ClkSrcSel | PWM external clock source. PWM_CLKSRC_PWM_CLK PWM_CLKSRC_TIMER0 PWM_CLKSRC_TIMER1 PWM_CLKSRC_TIMER2 PWM_CLKSRC_TIMER3

Returns
  None

This function is used to set PWM clock source.

Note
  Every two channels share the same setting.

Definition at line 812 of file pwm.c.

## ◆ PWM_Start()

void PWM_Start | ( | PWM_T * | pwm,
|  | uint32_t | u32ChannelMask
| ) |  |

Start PWM module.

Parameters

  [in] | pwm | The pointer of the specified PWM module PWM0 : PWM Group 0
  [in] | u32ChannelMask | Combination of enabled channels. Each bit corresponds to a channel. Every two channels share the same setting. Bit 0 is channel 0, bit 1 is channel 1...

Returns
  None

This function is used to start PWM module.

Definition at line 166 of file pwm.c.

## ◆ PWM_Stop()

void PWM_Stop | ( | PWM_T * | pwm,
|  | uint32_t | u32ChannelMask
| ) |  |

Stop PWM module.

Parameters

  [in] | pwm | The pointer of the specified PWM module PWM0 : PWM Group 0
  [in] | u32ChannelMask | Combination of enabled channels. Each bit corresponds to a channel. Every two channels share the same setting. Bit 0 is channel 0, bit 1 is channel 1...

Returns
  None

This function is used to stop PWM module.

Definition at line 187 of file pwm.c.