40 (timer)->PWMCLKSRC = ((timer)->PWMCLKSRC & ~TIMER_PWMCLKSRC_CLKSRC_Msk) | u32CntClkSrc;
57 uint32_t u32PWMClockFreq, u32TargetFreq;
58 uint32_t u32Prescaler = 0x1000UL, u32Period, u32CMP;
70 for(u32Prescaler = 1UL; u32Prescaler <= 0x1000UL; u32Prescaler++)
72 u32Period = (u32PWMClockFreq / u32Prescaler) / u32Frequency;
75 if(u32Period <= 0x10000UL)
81 u32TargetFreq = (u32PWMClockFreq / u32Prescaler) / u32Period;
95 u32CMP = (u32DutyCycle * u32Period) / 100UL;
104 return (u32TargetFreq);
179 timer->
PWMCTL &= ~TIMER_PWMCTL_CNTEN_Msk;
253 timer->
PWMFAILBRK |= ((u32BrakeSource >> 16) & 0xFUL);
310 return ((timer->
PWMINTSTS1 & (0x3UL << u32IntSource))? 1UL : 0UL);
394 timer->
PWMBNF &= ~TIMER_PWMBNF_BRKNFEN_Msk;
417 timer->
PWMBNF &= ~TIMER_PWMBNF_BRKPINV_Msk;
NuMicro peripheral access layer header file.
uint32_t CLK_GetPCLK1Freq(void)
Get PCLK1 frequency.
uint32_t CLK_GetPCLK0Freq(void)
Get PCLK0 frequency.
#define TIMER_PWMBRKCTL_BRKAEVEN_Msk
#define TIMER_PWMCTL_CNTEN_Msk
#define TIMER_PWMBNF_BRKPINV_Msk
#define TIMER_PWMBNF_BRKFCNT_Msk
#define TIMER_PWMBRKCTL_BRKAODD_Msk
#define TIMER_PWMBNF_BRKNFEN_Msk
#define TIMER_PWMEADCTS_TRGEN_Msk
#define TIMER_PWMBNF_BKPINSRC_Msk
#define TIMER_PWMBNF_BRKNFSEL_Pos
#define TIMER_PWMDTCTL_DTEN_Msk
#define TIMER_PWMBRKCTL_BRKAEVEN_Pos
#define TIMER_PWMDTCTL_DTCKSEL_Msk
#define TIMER_PWMCTL_IMMLDEN_Msk
#define TIMER_PWMBNF_BRKNFSEL_Msk
#define TIMER_PWMBRKCTL_BRKAODD_Pos
#define TIMER_PWMBNF_BKPINSRC_Pos
#define TIMER_PWMBNF_BRKFCNT_Pos
#define TIMER_PWMCTL_CNTTYPE_Pos
#define TIMER_PWMCTL_CTRLD_Msk
#define TPWM_AUTO_RELOAD_MODE
void TPWM_DisableBrakePinInverse(TIMER_T *timer)
Disable brake pin inverse function.
#define TPWM_SET_CMPDAT(timer, cmp)
Set Comparator Value.
void TPWM_EnableCounter(TIMER_T *timer)
Enable PWM Counter.
#define TPWM_SET_PERIOD(timer, period)
Set Counter Period.
void TPWM_SetBrakePinSource(TIMER_T *timer, uint32_t u32BrakePinNum)
Set brake pin source.
void TPWM_EnableBrakePinDebounce(TIMER_T *timer, uint32_t u32BrakePinSrc, uint32_t u32DebounceCnt, uint32_t u32ClkSrcSel)
Enable brake pin noise filter function.
void TPWM_EnableFaultBrakeInt(TIMER_T *timer, uint32_t u32IntSource)
Enable Fault Brake Interrupt.
void TPWM_EnableDeadTimeWithPrescale(TIMER_T *timer, uint32_t u32DTCount)
Enable Dead-Time Function.
void TPWM_DisableBrakePinDebounce(TIMER_T *timer)
Disable brake pin noise filter function.
void TPWM_SetLoadMode(TIMER_T *timer, uint32_t u32LoadMode)
Enable load mode of selected channel.
void TPWM_EnableBrakePinInverse(TIMER_T *timer)
Enable brake pin inverse function.
void TPWM_ClearFaultBrakeIntFlag(TIMER_T *timer, uint32_t u32IntSource)
Clear Fault Brake Interrupt Flags.
void TPWM_DisableTriggerADC(TIMER_T *timer)
Disable Trigger ADC.
void TPWM_DisableDeadTime(TIMER_T *timer)
Disable Dead-Time Function.
void TPWM_SetCounterClockSource(TIMER_T *timer, uint32_t u32CntClkSrc)
Set PWM Counter Clock Source.
uint32_t TPWM_ConfigOutputFreqAndDuty(TIMER_T *timer, uint32_t u32Frequency, uint32_t u32DutyCycle)
Configure PWM Output Frequency and Duty Cycle.
void TPWM_DisableCounter(TIMER_T *timer)
Disable PWM Generator.
void TPWM_DisableFaultBrakeInt(TIMER_T *timer, uint32_t u32IntSource)
Disable Fault Brake Interrupt.
void TPWM_EnableDeadTime(TIMER_T *timer, uint32_t u32DTCount)
Enable Dead-Time Function.
#define TPWM_SET_PRESCALER(timer, prescaler)
Set Counter Clock Prescaler.
uint32_t TPWM_GetFaultBrakeIntFlag(TIMER_T *timer, uint32_t u32IntSource)
Indicate Fault Brake Interrupt Flag.
void TPWM_EnableFaultBrake(TIMER_T *timer, uint32_t u32CH0Level, uint32_t u32CH1Level, uint32_t u32BrakeSource)
Enable Fault Brake Function.
void TPWM_EnableTriggerADC(TIMER_T *timer, uint32_t u32Condition)
Enable Trigger ADC.