Mini51 BSP  V3.02.002
The Board Support Package for Mini51 Series
Macros | Functions
PWM Exported Functions

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_GROUP_MODE(pwm)
 This macro enable group mode. More...
 
#define PWM_DISABLE_GROUP_MODE(pwm)
 This macro disable group mode. More...
 
#define PWM_ENABLE_SYNC_MODE(pwm)
 This macro enable synchronous mode. More...
 
#define PWM_DISABLE_SYNC_MODE(pwm)
 This macro disable synchronous 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_SET_PRESCALER(pwm, u32ChannelNum, u32Prescaler)
 This macro set the prescaler of the selected channel. More...
 
#define PWM_SET_DIVIDER(pwm, u32ChannelNum, u32Divider)
 This macro set the divider of the selected channel. More...
 
#define PWM_SET_CMR(pwm, u32ChannelNum, u32CMR)
 This macro set the duty 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...
 

Functions

uint32_t PWM_ConfigOutputChannel (PWM_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 PWM_Start (PWM_T *pwm, uint32_t u32ChannelMask)
 This function start PWM module. More...
 
void PWM_Stop (PWM_T *pwm, uint32_t u32ChannelMask)
 This function stop PWM module. More...
 
void PWM_ForceStop (PWM_T *pwm, uint32_t u32ChannelMask)
 This function stop PWM generation immediately by clear channel enable bit. More...
 
void PWM_EnableADCTrigger (PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32Condition)
 This function enable selected channel to trigger ADC. More...
 
void PWM_DisableADCTrigger (PWM_T *pwm, uint32_t u32ChannelNum)
 This function disable selected channel to trigger ADC. More...
 
void PWM_ClearADCTriggerFlag (PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32Condition)
 This function clear selected channel trigger ADC flag. More...
 
uint32_t PWM_GetADCTriggerFlag (PWM_T *pwm, uint32_t u32ChannelNum)
 This function 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 channels. More...
 
void PWM_ClearFaultBrakeFlag (PWM_T *pwm, uint32_t u32BrakeSource)
 This function clear fault brake flag. More...
 
void PWM_EnableOutput (PWM_T *pwm, uint32_t u32ChannelMask)
 This function enables PWM output generation of selected channels. More...
 
void PWM_DisableOutput (PWM_T *pwm, uint32_t u32ChannelMask)
 This function disables PWM output generation of selected channels. More...
 
void PWM_EnableDeadZone (PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32Duration)
 This function enable Dead zone of selected channel. More...
 
void PWM_DisableDeadZone (PWM_T *pwm, uint32_t u32ChannelNum)
 This function disable Dead zone of selected channel. More...
 
void PWM_EnableDutyInt (PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32IntDutyType)
 This function enable duty interrupt of selected channel. More...
 
void PWM_DisableDutyInt (PWM_T *pwm, uint32_t u32ChannelNum)
 This function disable duty interrupt of selected channel. More...
 
void PWM_ClearDutyIntFlag (PWM_T *pwm, uint32_t u32ChannelNum)
 This function clears duty interrupt flag of selected channel. More...
 
uint32_t PWM_GetDutyIntFlag (PWM_T *pwm, uint32_t u32ChannelNum)
 This function get duty interrupt flag 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 of selected source. More...
 
void PWM_EnablePeriodInt (PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32IntPeriodType)
 This function enable period interrupt of selected channel. More...
 
void PWM_DisablePeriodInt (PWM_T *pwm, uint32_t u32ChannelNum)
 This function disable period interrupt of selected channel. More...
 
void PWM_ClearPeriodIntFlag (PWM_T *pwm, uint32_t u32ChannelNum)
 This function clear period interrupt of selected channel. More...
 
uint32_t PWM_GetPeriodIntFlag (PWM_T *pwm, uint32_t u32ChannelNum)
 This function get period interrupt of selected channel. More...
 

Detailed Description

Macro Definition Documentation

◆ PWM_DISABLE_COMPLEMENTARY_MODE

#define PWM_DISABLE_COMPLEMENTARY_MODE (   pwm)

This macro disable complementary mode, and enable independent mode.

Parameters
[in]pwmThe base address of PWM module
Returns
None

Definition at line 72 of file pwm.h.

◆ PWM_DISABLE_GROUP_MODE

#define PWM_DISABLE_GROUP_MODE (   pwm)

This macro disable group mode.

Parameters
[in]pwmThe base address of PWM module
Returns
None

Definition at line 88 of file pwm.h.

◆ PWM_DISABLE_SYNC_MODE

#define PWM_DISABLE_SYNC_MODE (   pwm)

This macro disable synchronous mode, and enable independent mode.

Parameters
[in]pwmThe base address of PWM module
Returns
None

Definition at line 104 of file pwm.h.

◆ PWM_ENABLE_COMPLEMENTARY_MODE

#define PWM_ENABLE_COMPLEMENTARY_MODE (   pwm)

This macro enable complementary mode.

Parameters
[in]pwmThe base address of PWM module
Returns
None

Definition at line 64 of file pwm.h.

◆ PWM_ENABLE_GROUP_MODE

#define PWM_ENABLE_GROUP_MODE (   pwm)

This macro enable group mode.

Parameters
[in]pwmThe base address of PWM module
Returns
None

Definition at line 80 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]pwmThe base address of PWM module
[in]u32ChannelMaskCombination of enabled channels. Each bit corresponds to a channel Bit 0 represents channel 0, bit 1 represents channel 1...
Returns
None

Definition at line 114 of file pwm.h.

◆ PWM_ENABLE_SYNC_MODE

#define PWM_ENABLE_SYNC_MODE (   pwm)

This macro enable synchronous mode.

Parameters
[in]pwmThe base address of PWM module
Returns
None

Definition at line 96 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]pwmThe base address of PWM module
[in]u32ChannelMaskThis parameter is not used
[in]u32AlignedTypePWM aligned type, valid values are:
  • PWM_EDGE_ALIGNED
  • PWM_CENTER_ALIGNED
Returns
None

Definition at line 186 of file pwm.h.

◆ PWM_SET_CMR

#define PWM_SET_CMR (   pwm,
  u32ChannelNum,
  u32CMR 
)

This macro set the duty of the selected channel.

Parameters
[in]pwmThe base address of PWM module
[in]u32ChannelNumPWM channel number. Valid values are between 0~5
[in]u32CMRDuty 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 162 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]pwmThe base address of PWM module
[in]u32ChannelNumPWM channel number. Valid values are between 0~5
[in]u32CNRPeriod 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 174 of file pwm.h.

◆ PWM_SET_DIVIDER

#define PWM_SET_DIVIDER (   pwm,
  u32ChannelNum,
  u32Divider 
)

This macro set the divider of the selected channel.

Parameters
[in]pwmThe base address of PWM module
[in]u32ChannelNumPWM channel number. Valid values are between 0~5
[in]u32DividerClock divider of specified channel. Valid values are
Returns
None

Definition at line 150 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]pwmThe base address of PWM module
[in]u32ChannelNumPWM channel number. Valid values are between 0~5
[in]u32PrescalerClock prescaler of specified channel. Valid values are between 1 ~ 0xFF
Returns
None
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 134 of file pwm.h.

Function Documentation

◆ PWM_ClearADCTriggerFlag()

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

This function clear selected channel trigger ADC flag.

Parameters
[in]pwmThe base address of PWM module
[in]u32ChannelNumPWM channel number. Valid values are between 0~5
[in]u32ConditionPWM triggered ADC flag to be cleared. A combination of following flags:
Returns
None

Definition at line 230 of file pwm.c.

◆ PWM_ClearDutyIntFlag()

void PWM_ClearDutyIntFlag ( PWM_T pwm,
uint32_t  u32ChannelNum 
)

This function clears duty interrupt flag of selected channel.

Parameters
[in]pwmThe base address of PWM module
[in]u32ChannelNumPWM channel number. Valid values are between 0~5
Returns
None

Definition at line 390 of file pwm.c.

◆ PWM_ClearFaultBrakeFlag()

void PWM_ClearFaultBrakeFlag ( PWM_T pwm,
uint32_t  u32BrakeSource 
)

This function clear fault brake flag.

Parameters
[in]pwmThe base address of PWM module
[in]u32BrakeSourceThis 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 300 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]pwmThe base address of PWM module
[in]u32BrakeSourceFault brake source, could be either
Returns
None

Definition at line 438 of file pwm.c.

◆ PWM_ClearPeriodIntFlag()

void PWM_ClearPeriodIntFlag ( PWM_T pwm,
uint32_t  u32ChannelNum 
)

This function clear period interrupt of selected channel.

Parameters
[in]pwmThe base address of PWM module
[in]u32ChannelNumPWM channel number. Valid values are between 0~5
Returns
None

Definition at line 490 of file pwm.c.

◆ PWM_ConfigOutputChannel()

uint32_t PWM_ConfigOutputChannel ( PWM_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]pwmThe base address of PWM module
[in]u32ChannelNumPWM channel number. Valid values are between 0~5
[in]u32FrequencyTarget generator frequency
[in]u32DutyCycleTarget 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), (4 & 5), shares a prescaler. Call this API to configure PWM frequency may affect existing frequency of other channel.

Definition at line 37 of file pwm.c.

◆ PWM_DisableADCTrigger()

void PWM_DisableADCTrigger ( PWM_T pwm,
uint32_t  u32ChannelNum 
)

This function disable selected channel to trigger ADC.

Parameters
[in]pwmThe base address of PWM module
[in]u32ChannelNumPWM channel number. Valid values are between 0~5
Returns
None

Definition at line 201 of file pwm.c.

◆ PWM_DisableDeadZone()

void PWM_DisableDeadZone ( PWM_T pwm,
uint32_t  u32ChannelNum 
)

This function disable Dead zone of selected channel.

Parameters
[in]pwmThe base address of PWM module
[in]u32ChannelNumPWM channel number. Valid values are between 0~5
Returns
None

Definition at line 353 of file pwm.c.

◆ PWM_DisableDutyInt()

void PWM_DisableDutyInt ( PWM_T pwm,
uint32_t  u32ChannelNum 
)

This function disable duty interrupt of selected channel.

Parameters
[in]pwmThe base address of PWM module
[in]u32ChannelNumPWM channel number. Valid values are between 0~5
Returns
None

Definition at line 379 of file pwm.c.

◆ PWM_DisableFaultBrakeInt()

void PWM_DisableFaultBrakeInt ( PWM_T pwm,
uint32_t  u32BrakeSource 
)

This function disable fault brake interrupt.

Parameters
[in]pwmThe base address of PWM module
[in]u32BrakeSourceThis parameter is not used
Returns
None

Definition at line 425 of file pwm.c.

◆ PWM_DisableOutput()

void PWM_DisableOutput ( PWM_T pwm,
uint32_t  u32ChannelMask 
)

This function disables PWM output generation of selected channels.

Parameters
[in]pwmThe base address of PWM module
[in]u32ChannelMaskCombination 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 324 of file pwm.c.

◆ PWM_DisablePeriodInt()

void PWM_DisablePeriodInt ( PWM_T pwm,
uint32_t  u32ChannelNum 
)

This function disable period interrupt of selected channel.

Parameters
[in]pwmThe base address of PWM module
[in]u32ChannelNumPWM channel number. Valid values are between 0~5
Returns
None

Definition at line 479 of file pwm.c.

◆ PWM_EnableADCTrigger()

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

This function enable selected channel to trigger ADC.

Parameters
[in]pwmThe base address of PWM module
[in]u32ChannelNumPWM channel number. Valid values are between 0~5
[in]u32ConditionThe condition to trigger ADC. Combination of following conditions:
Returns
None

Definition at line 176 of file pwm.c.

◆ PWM_EnableDeadZone()

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

This function enable Dead zone of selected channel.

Parameters
[in]pwmThe base address of PWM module
[in]u32ChannelNumPWM channel number. Valid values are between 0~5
[in]u32DurationDead Zone length in PWM clock count, valid values are between 0~0xFF, but 0 means there is no dead zone.
Returns
None

Definition at line 337 of file pwm.c.

◆ PWM_EnableDutyInt()

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

This function enable duty interrupt of selected channel.

Parameters
[in]pwmThe base address of PWM module
[in]u32ChannelNumPWM channel number. Valid values are between 0~5
[in]u32IntDutyTypeThis parameter is not used
Returns
None

Definition at line 368 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 channels.

Parameters
[in]pwmThe base address of PWM module
[in]u32ChannelMaskThis parameter is not used
[in]u32LevelMaskOutput high or low while fault brake occurs, each bit represent the level of a channel while fault brake occur. Bit 0 represents channel 0, bit 1 represents channel 1... , bit 6 represent D6, and bit 7 represents D7
[in]u32BrakeSourceFault brake source, could be one of following source
Returns
None

Definition at line 285 of file pwm.c.

◆ PWM_EnableFaultBrakeInt()

void PWM_EnableFaultBrakeInt ( PWM_T pwm,
uint32_t  u32BrakeSource 
)

This function enable fault brake interrupt.

Parameters
[in]pwmThe base address of PWM module
[in]u32BrakeSourceThis parameter is not used
Returns
None

Definition at line 414 of file pwm.c.

◆ PWM_EnableOutput()

void PWM_EnableOutput ( PWM_T pwm,
uint32_t  u32ChannelMask 
)

This function enables PWM output generation of selected channels.

Parameters
[in]pwmThe base address of PWM module
[in]u32ChannelMaskCombination 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 312 of file pwm.c.

◆ PWM_EnablePeriodInt()

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

This function enable period interrupt of selected channel.

Parameters
[in]pwmThe base address of PWM module
[in]u32ChannelNumPWM channel number. Valid values are between 0~5
[in]u32IntPeriodTypePeriod interrupt type, could be either
Returns
None
Note
All channels share the same period interrupt type setting.

Definition at line 468 of file pwm.c.

◆ PWM_ForceStop()

void PWM_ForceStop ( PWM_T pwm,
uint32_t  u32ChannelMask 
)

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

Parameters
[in]pwmThe base address of PWM module
[in]u32ChannelMaskCombination of enabled channels. Each bit corresponds to a channel. Bit 0 is channel 0, bit 1 is channel 1...
Returns
None

Definition at line 151 of file pwm.c.

◆ PWM_GetADCTriggerFlag()

uint32_t PWM_GetADCTriggerFlag ( PWM_T pwm,
uint32_t  u32ChannelNum 
)

This function get selected channel trigger ADC flag.

Parameters
[in]pwmThe base address of PWM module
[in]u32ChannelNumPWM channel number. Valid values are between 0~5
Returns
Combination of following trigger conditions which triggered ADC

Definition at line 252 of file pwm.c.

◆ PWM_GetDutyIntFlag()

uint32_t PWM_GetDutyIntFlag ( PWM_T pwm,
uint32_t  u32ChannelNum 
)

This function get duty interrupt flag of selected channel.

Parameters
[in]pwmThe base address of PWM module
[in]u32ChannelNumPWM channel number. Valid values are between 0~5
Returns
Duty interrupt flag of specified channel
Return values
0Duty interrupt did not occurred
1Duty interrupt occurred

Definition at line 403 of file pwm.c.

◆ PWM_GetFaultBrakeIntFlag()

uint32_t PWM_GetFaultBrakeIntFlag ( PWM_T pwm,
uint32_t  u32BrakeSource 
)

This function get fault brake interrupt of selected source.

Parameters
[in]pwmThe base address of PWM module
[in]u32BrakeSourceFault brake source, could be either
Returns
Fault brake interrupt flag of specified source
Return values
0Fault brake interrupt did not occurred
1Fault brake interrupt occurred

Definition at line 453 of file pwm.c.

◆ PWM_GetPeriodIntFlag()

uint32_t PWM_GetPeriodIntFlag ( PWM_T pwm,
uint32_t  u32ChannelNum 
)

This function get period interrupt of selected channel.

Parameters
[in]pwmThe base address of PWM module
[in]u32ChannelNumPWM channel number. Valid values are between 0~5
Returns
Period interrupt flag of specified channel
Return values
0Period interrupt did not occurred
1Period interrupt occurred

Definition at line 503 of file pwm.c.

◆ PWM_Start()

void PWM_Start ( PWM_T pwm,
uint32_t  u32ChannelMask 
)

This function start PWM module.

Parameters
[in]pwmThe base address of PWM module
[in]u32ChannelMaskCombination of enabled channels. Each bit corresponds to a channel. Bit 0 is channel 0, bit 1 is channel 1...
Returns
None

Definition at line 110 of file pwm.c.

◆ PWM_Stop()

void PWM_Stop ( PWM_T pwm,
uint32_t  u32ChannelMask 
)

This function stop PWM module.

Parameters
[in]pwmThe base address of PWM module
[in]u32ChannelMaskCombination of enabled channels. Each bit corresponds to a channel. Bit 0 is channel 0, bit 1 is channel 1...
Returns
None

Definition at line 131 of file pwm.c.