36 uint32_t u32ChannelNum,
37 uint32_t u32Frequency,
38 uint32_t u32DutyCycle)
41 uint32_t u32PWM_CLock;
42 uint8_t u8Divider = 1;
43 uint16_t u16CNR = 0xFFFF;
47 for(; u8Divider < 17; u8Divider <<= 1)
53 i = (u32PWM_CLock / u32Frequency) / u8Divider;
71 i = u32PWM_CLock / (u8Divider * u16CNR);
77 else if (u8Divider == 2)
79 else if (u8Divider == 4)
87 pwm->
CMPDAT[u32ChannelNum >> 1] = 0;
89 pwm->
CMPDAT[u32ChannelNum >> 1] = u32DutyCycle * (u16CNR + 1) / 100 - 1;
118 pwm->
CTL &= ~EPWM_CTL_CNTEN_Msk;
130 pwm->
CTL &= ~EPWM_CTL_CNTEN_Msk;
153 uint32_t u32ChannelMask,
154 uint32_t u32LevelMask,
155 uint32_t u32BrakeSource)
164 pwm->
BRKOUT = (pwm->
BRKOUT & ~EPWM_BRKOUT_BRKOUT_Msk) | u32LevelMask;
189 if (u32ChannelMask & 0x15)
191 if (u32ChannelMask & 0x2A)
204 if (u32ChannelMask & 0x15)
205 pwm->
OUTEN0 &= ~EPWM_OUTEN0_EVENOUTEN_Msk;
206 if (u32ChannelMask & 0x2A)
207 pwm->
OUTEN0 &= ~EPWM_OUTEN0_ODDOUTEN_Msk;
223 pwm->
DTCTL = (pwm->
DTCTL & ~EPWM_DTCTL_DTCNT_Msk) | u32Duration;
318 pwm->
CTL &= ~EPWM_CTL_BRKIEN_Msk;
331 pwm->
STATUS = u32BrakeSource;
346 return (pwm->
STATUS & u32BrakeSource ? 1 : 0);
371 pwm->
CTL &= ~EPWM_CTL_PWMIEN_Msk;
NUC472/NUC442 peripheral access layer header file. This file contains all the peripheral register's d...
#define EPWM_CTL_BRKIEN_Msk
#define EPWM_OUTEN0_ODDOUTEN_Msk
#define EPWM_CTL_PWMIEN_Msk
#define EPWM_CTL_BRKP1EN_Msk
#define EPWM_STATUS_EIF0_Msk
#define EPWM_STATUS_PIF_Msk
#define EPWM_CTL_INTTYPE_Msk
#define EPWM_DTCTL_DTEN0_Msk
#define EPWM_STATUS_BRKIF0_Msk
#define EPWM_OUTEN0_EVENOUTEN_Msk
#define EPWM_EINTCTL_EDGEIEN0_Msk
#define EPWM_CTL_CLKDIV_Pos
#define EPWM_EINTCTL_EINTTYPE0_Msk
#define EPWM_CTL_CNTEN_Msk
#define EPWM_STATUS_BRK0LOCK_Msk
#define EPWM_CTL_BRKP0EN_Msk
#define EPWM_BRK1_LVDBKEN
uint32_t EPWM_GetPeriodIntFlag(EPWM_T *pwm, uint32_t u32ChannelNum)
This function get period interrupt of selected channel.
void EPWM_DisableDutyInt(EPWM_T *pwm, uint32_t u32ChannelNum)
This function disable duty interrupt of selected channel.
uint32_t EPWM_GetDutyIntFlag(EPWM_T *pwm, uint32_t u32ChannelNum)
This function get duty interrupt flag of selected channel.
void EPWM_DisableFaultBrakeInt(EPWM_T *pwm, uint32_t u32BrakeSource)
This function disable fault brake interrupt.
void EPWM_Stop(EPWM_T *pwm, uint32_t u32ChannelMask)
This function stop PWM module.
void EPWM_DisableDeadZone(EPWM_T *pwm, uint32_t u32ChannelNum)
This function disable Dead zone of selected channel.
void EPWM_DisableOutput(EPWM_T *pwm, uint32_t u32ChannelMask)
This function disables PWM output generation of selected channels.
void EPWM_ClearDutyIntFlag(EPWM_T *pwm, uint32_t u32ChannelNum)
This function clears duty interrupt flag of selected channel.
void EPWM_DisablePeriodInt(EPWM_T *pwm, uint32_t u32ChannelNum)
This function disable period interrupt of selected channel.
void EPWM_EnableFaultBrake(EPWM_T *pwm, uint32_t u32ChannelMask, uint32_t u32LevelMask, uint32_t u32BrakeSource)
This function enable fault brake of selected channels.
void EPWM_ForceStop(EPWM_T *pwm, uint32_t u32ChannelMask)
This function stop PWM generation immediately by clear channel enable bit.
void EPWM_ClearFaultBrakeFlag(EPWM_T *pwm, uint32_t u32BrakeSource)
This function clear fault brake flag.
void EPWM_EnableFaultBrakeInt(EPWM_T *pwm, uint32_t u32BrakeSource)
This function enable fault brake interrupt.
void EPWM_Start(EPWM_T *pwm, uint32_t u32ChannelMask)
This function start PWM module.
void EPWM_EnablePeriodInt(EPWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32IntPeriodType)
This function enable period interrupt of selected channel.
void EPWM_EnableOutput(EPWM_T *pwm, uint32_t u32ChannelMask)
This function enables PWM output generation of selected channels.
void EPWM_EnableDutyInt(EPWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32IntDutyType)
This function enable duty interrupt of selected channel.
void EPWM_EnableDeadZone(EPWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32Duration)
This function enable Dead zone of selected channel.
void EPWM_ClearFaultBrakeIntFlag(EPWM_T *pwm, uint32_t u32BrakeSource)
This function clear fault brake interrupt of selected source.
void EPWM_ClearPeriodIntFlag(EPWM_T *pwm, uint32_t u32ChannelNum)
This function clear period interrupt of selected channel.
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.
uint32_t EPWM_GetFaultBrakeIntFlag(EPWM_T *pwm, uint32_t u32BrakeSource)
This function get fault brake interrupt of selected source.