NANO102/112 BSP V3.03.003
The Board Support Package for Nano102/112 Series
Macros | Functions
Collaboration diagram for PWM Exported Functions:

Macros

#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_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...
 
uint32_t PWM_ConfigCaptureChannel (PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32UnitTimeNsec, uint32_t u32CaptureEdge)
 This function config PWM capture and get the nearest unit time. 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_EnableCapture (PWM_T *pwm, uint32_t u32ChannelMask)
 This function enables PWM capture of selected channels. More...
 
void PWM_DisableCapture (PWM_T *pwm, uint32_t u32ChannelMask)
 This function disables PWM capture of selected channels. 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_EnableCaptureInt (PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32Edge)
 This function enable capture interrupt of selected channel. More...
 
void PWM_DisableCaptureInt (PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32Edge)
 This function disable capture interrupt of selected channel. More...
 
void PWM_ClearCaptureIntFlag (PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32Edge)
 This function clear capture interrupt flag of selected channel. More...
 
uint32_t PWM_GetCaptureIntFlag (PWM_T *pwm, uint32_t u32ChannelNum)
 This function get capture interrupt flag of selected channel. More...
 
void PWM_EnableDutyInt (PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32IntDutyType)
 
void PWM_DisableDutyInt (PWM_T *pwm, uint32_t u32ChannelNum)
 
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_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...
 
void PWM_EnablePDMA (PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32RisingFirst, uint32_t u32Mode)
 This function enable capture PDMA of selected channel. More...
 
void PWM_DisablePDMA (PWM_T *pwm, uint32_t u32ChannelNum)
 This function disable capture PDMA of selected channel. More...
 

Detailed Description

Macro Definition Documentation

◆ 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 75 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]pwmThe base address of PWM module
[in]u32ChannelNumPWM channel number. Valid values are between 0~5
Returns
None

Definition at line 102 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]pwmThe base address of PWM module
[in]u32ChannelNumPWM channel number. Valid values are between 0~5
Returns
None

Definition at line 93 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]u32ChannelMaskCombination of enabled channels. Each bit corresponds to a channel Bit 0 represents channel 0, bit 1 represents channel 1...
[in]u32AlignedTypePWM aligned type, valid values are:
Returns
None

Definition at line 175 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 142 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 158 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 130 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 114 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]u32ConditionThis parameter is not used
Returns
None

Definition at line 301 of file pwm.c.

◆ PWM_ClearCaptureIntFlag()

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

This function clear capture interrupt flag of selected channel.

Parameters
[in]pwmThe base address of PWM module
[in]u32ChannelNumPWM channel number. Valid values are between 0~5
[in]u32EdgeCapture interrupt type. It could be either
Returns
None

Definition at line 469 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 496 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 546 of file pwm.c.

◆ PWM_ConfigCaptureChannel()

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

This function config PWM capture and get the nearest unit time.

Parameters
[in]pwmThe base address of PWM module
[in]u32ChannelNumPWM channel number. Valid values are between 0~5
[in]u32UnitTimeNsecUnit time of counter
[in]u32CaptureEdgeCondition to latch the counter
Returns
Nearest unit time 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 138 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 289 of file pwm.c.

◆ PWM_DisableCapture()

void PWM_DisableCapture ( PWM_T pwm,
uint32_t  u32ChannelMask 
)

This function disables PWM capture 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 350 of file pwm.c.

◆ PWM_DisableCaptureInt()

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

This function disable capture interrupt of selected channel.

Parameters
[in]pwmThe base address of PWM module
[in]u32ChannelNumPWM channel number. Valid values are between 0~5
[in]u32EdgeCapture interrupt type. It could be either
Returns
None

Definition at line 453 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 419 of file pwm.c.

◆ PWM_DisableDutyInt()

void PWM_DisableDutyInt ( PWM_T pwm,
uint32_t  u32ChannelNum 
)

◆ 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 390 of file pwm.c.

◆ PWM_DisablePDMA()

void PWM_DisablePDMA ( PWM_T pwm,
uint32_t  u32ChannelNum 
)

This function disable capture PDMA of selected channel.

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

Definition at line 592 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 535 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]u32ConditionThis parameter is not used
Returns
None

Definition at line 278 of file pwm.c.

◆ PWM_EnableCapture()

void PWM_EnableCapture ( PWM_T pwm,
uint32_t  u32ChannelMask 
)

This function enables PWM capture 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 327 of file pwm.c.

◆ PWM_EnableCaptureInt()

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

This function enable capture interrupt of selected channel.

Parameters
[in]pwmThe base address of PWM module
[in]u32ChannelNumPWM channel number. Valid values are between 0~5
[in]u32EdgeCapture interrupt type. It could be either
Returns
None

Definition at line 437 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 403 of file pwm.c.

◆ PWM_EnableDutyInt()

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

◆ 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 378 of file pwm.c.

◆ PWM_EnablePDMA()

void PWM_EnablePDMA ( PWM_T pwm,
uint32_t  u32ChannelNum,
uint32_t  u32RisingFirst,
uint32_t  u32Mode 
)

This function enable capture PDMA of selected channel.

Parameters
[in]pwmThe base address of PWM module
[in]u32ChannelNumPWM channel number. Valid values are 0 and 2
[in]u32RisingFirstOrder of captured data transferred by PDMA. It could be either
[in]u32ModeCaptured data transferred by PDMA interrupt type. It could be either
Returns
None

Definition at line 578 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]u32IntPeriodTypeThis parameter is not used
Returns
None
Note
All channels share the same period interrupt type setting.

Definition at line 523 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 261 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
Trigger ADC or not
Return values
0The designated channel did not trigger ADC
1The designated channel triggered ADC

Definition at line 314 of file pwm.c.

◆ PWM_GetCaptureIntFlag()

uint32_t PWM_GetCaptureIntFlag ( PWM_T pwm,
uint32_t  u32ChannelNum 
)

This function get capture interrupt flag of selected channel.

Parameters
[in]pwmThe base address of PWM module
[in]u32ChannelNumPWM channel number. Valid values are between 0~5
Returns
Capture interrupt flag of specified channel
Return values
0Capture interrupt did not occurred
PWM_RISING_LATCH_INT_FLAGRising edge latch interrupt occurred
PWM_FALLING_LATCH_INT_FLAGFalling edge latch interrupt occurred
PWM_RISING_FALLING_LATCH_INT_FLAGRising and falling edge latch interrupt occurred

Definition at line 485 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 510 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 560 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 220 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 241 of file pwm.c.