38 uint32_t u32ChannelNum,
39 uint32_t u32Frequency,
40 uint32_t u32DutyCycle)
43 uint8_t u8Divider = 1, u8Prescale = 0xFF;
44 uint16_t u16CNR = 0xFFFF;
46 for(; u8Divider < 17; u8Divider <<= 1)
50 if(i > (0x10000 * 0x100))
54 u8Prescale = (i + 0xFFFF)/ 0x10000;
80 else if (u8Divider == 2)
82 else if (u8Divider == 4)
84 else if (u8Divider == 8)
94 PWM->CMPDAT[u32ChannelNum] = 0;
96 PWM->CMPDAT[u32ChannelNum] = u32DutyCycle * (u16CNR + 1) / 100 - 1;
97 PWM->PERIOD[u32ChannelNum] = u16CNR;
112 uint32_t u32Mask = 0, i;
115 if(u32ChannelMask & (1 << i))
136 if(u32ChannelMask & (1 << i))
153 uint32_t u32Mask = 0, i;
156 if(u32ChannelMask & (1 << i))
162 PWM->CTL &= ~u32Mask;
178 if(u32ChannelNum < 4)
203 if(u32ChannelNum < 4)
232 if(u32ChannelNum < 4)
234 PWM->ADCTSTS0 |= (u32Condition << (8 * u32ChannelNum));
238 PWM->ADCTSTS1 |= (u32Condition << (8 * (u32ChannelNum - 4)));
251 if(u32ChannelNum < 4)
253 return(
PWM->ADCTSTS0 & (u32Condition << (8 * u32ChannelNum)) ? 1 : 0);
257 return(
PWM->ADCTSTS1 & (u32Condition << (8 * (u32ChannelNum - 4))) ? 1 : 0);
276 uint32_t u32ChannelMask,
277 uint32_t u32LevelMask,
278 uint32_t u32BrakeSource)
304 PWM->POEN |= u32ChannelMask;
316 PWM->POEN &= ~u32ChannelMask;
509 PWM->INTEN &= ~PWM_INTEN_BRKIEN_Msk;
522 PWM->INTSTS = u32BrakeSource;
537 return (
PWM->INTSTS & u32BrakeSource ? 1 : 0);
Mini55 series peripheral access layer header file. This file contains all the peripheral register's d...
#define PWM_INTSTS_CMPDIF0_Msk
#define PWM_CTL_CNTEN0_Msk
#define PWM_INTSTS_CMPUIF0_Msk
#define PWM_CLKDIV_CLKDIV0_Msk
#define PWM_INTEN_PIEN0_Msk
#define PWM_INTEN_CMPUIEN0_Pos
#define PWM_DTCTL_DTCNT01_Msk
#define PWM_BRKCTL_BKOD0_Pos
#define PWM_CTL_CNTMODE0_Msk
#define PWM_CTL_DTCNT01_Msk
#define PWM_BRKCTL_BRKSTS_Msk
#define PWM_INTEN_ZIEN0_Pos
#define PWM_INTSTS_ZIF0_Msk
#define PWM_INTEN_ZIEN0_Msk
#define PWM_INTEN_CMPDIEN0_Msk
#define PWM_INTSTS_PIF0_Msk
#define PWM_INTEN_BRKIEN_Msk
#define PWM_CLKPSC_CLKPSC01_Msk
#define PWM_TRIGGER_ADC_CNTR_IS_0
#define PWM_TRIGGER_ADC_CNTR_IS_CMR_U
#define PWM_TRIGGER_ADC_CNTR_IS_CNR
#define PWM_TRIGGER_ADC_CNTR_IS_CMR_D
void PWM_ForceStop(PWM_T *pwm, uint32_t u32ChannelMask)
This function stop PWM generation immediately by clear channel enable bit.
void PWM_Stop(PWM_T *pwm, uint32_t u32ChannelMask)
This function stop PWM module.
void PWM_EnableDeadZone(PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32Duration)
This function enable Dead zone of selected channel.
void PWM_ClearADCTriggerFlag(PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32Condition)
This function clear selected channel trigger ADC flag.
void PWM_DisableADCTrigger(PWM_T *pwm, uint32_t u32ChannelNum)
This function disable selected channel to trigger ADC.
void PWM_DisableRiseInt(PWM_T *pwm, uint32_t u32ChannelNum)
This function disable Rise interrupt of selected channel.
void PWM_ClearRiseIntFlag(PWM_T *pwm, uint32_t u32ChannelNum)
This function clears Rise interrupt flag of selected channel.
void PWM_DisablePeriodInt(PWM_T *pwm, uint32_t u32ChannelNum)
This function disable Period interrupt of selected channel.
void PWM_EnableDutyInt(PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32IntDutyType)
This function enable duty interrupt of selected channel.
uint32_t PWM_GetFaultBrakeIntFlag(PWM_T *pwm, uint32_t u32BrakeSource)
This function get fault brake interrupt of selected source.
void PWM_DisableFaultBrakeInt(PWM_T *pwm, uint32_t u32BrakeSource)
This function disable fault brake interrupt.
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.
void PWM_EnablePeriodInt(PWM_T *pwm, uint32_t u32ChannelNum)
This function enable Period interrupt of selected channel.
void PWM_DisableCenterInt(PWM_T *pwm, uint32_t u32ChannelNum)
This function disable Central interrupt of selected channel.
void PWM_EnableRiseInt(PWM_T *pwm, uint32_t u32ChannelNum)
This function enable Rise interrupt of selected channel.
void PWM_DisableDutyInt(PWM_T *pwm, uint32_t u32ChannelNum)
This function disable duty interrupt of selected channel.
uint32_t PWM_GetADCTriggerFlag(PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32Condition)
This function get selected channel trigger ADC flag.
void PWM_ClearDutyIntFlag(PWM_T *pwm, uint32_t u32ChannelNum)
This function clears duty interrupt flag of selected channel.
void PWM_EnableFaultBrake(PWM_T *pwm, uint32_t u32ChannelMask, uint32_t u32LevelMask, uint32_t u32BrakeSource)
This function enable fault brake of selected channels.
uint32_t PWM_GetDutyIntFlag(PWM_T *pwm, uint32_t u32ChannelNum)
This function get duty interrupt flag of selected channel.
void PWM_DisableDeadZone(PWM_T *pwm, uint32_t u32ChannelNum)
This function disable Dead zone of selected channel.
void PWM_DisableOutput(PWM_T *pwm, uint32_t u32ChannelMask)
This function disables PWM output generation of selected channels.
void PWM_EnableCenterInt(PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32IntPeriodType)
This function enable Central interrupt of selected channel.
void PWM_ClearCenterIntFlag(PWM_T *pwm, uint32_t u32ChannelNum)
This function clear Central interrupt of selected channel.
uint32_t PWM_GetRiseIntFlag(PWM_T *pwm, uint32_t u32ChannelNum)
This function get Rise interrupt flag of selected channel.
void PWM_ClearFaultBrakeIntFlag(PWM_T *pwm, uint32_t u32BrakeSource)
This function clear fault brake interrupt of selected source.
void PWM_Start(PWM_T *pwm, uint32_t u32ChannelMask)
This function start PWM module.
void PWM_ClearPeriodIntFlag(PWM_T *pwm, uint32_t u32ChannelNum)
This function clears Period interrupt flag of selected channel.
void PWM_EnableOutput(PWM_T *pwm, uint32_t u32ChannelMask)
This function enables PWM output generation of selected channels.
void PWM_EnableFaultBrakeInt(PWM_T *pwm, uint32_t u32BrakeSource)
This function enable fault brake interrupt.
uint32_t PWM_GetPeriodIntFlag(PWM_T *pwm, uint32_t u32ChannelNum)
This function get Period interrupt flag of selected channel.
void PWM_ClearFaultBrakeFlag(PWM_T *pwm, uint32_t u32BrakeSource)
This function clear fault brake flag.
uint32_t PWM_GetCenterIntFlag(PWM_T *pwm, uint32_t u32ChannelNum)
This function get Central interrupt of selected channel.
void PWM_EnableADCTrigger(PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32Condition)
This function enable selected channel to trigger ADC.
#define PWM
Pointer to PWM register structure.