AnsweredAssumed Answered

PWM output by K64 FTM0 is not stable

Question asked by HUIQI LI on Sep 24, 2018
Latest reply on Sep 29, 2018 by Jing Pan

Hello, Sir/Madam:

 

I encountered a problem relating to PWM output by FTM. The uC used is K64. I used 2 FTM to output 4-channel PWM output. The port is GPIOC, pin 8 and 9, configured as FTM3 channel 4 and 5 (kPORT_MuxAlt3); GPIOD 5 and 6, configured as FTM0 channel 5 and 6 (kPORT_MuxAlt4).

 

The FTM configuration is listed below. And I updated the PWM output when timeout interrupt is triggered, with function FTM_UpdatePwmDutycycle and FTM_SetSoftwareTrigger. The problem is the output in 2-channel controlled by FTM3 is correct, while the output controlled by FTM0 is not stable. It seems there is something like periodical high level output in 2 FTM0 controlled channel. Could you let me know what the problem it might be, and/or how to do further analysis. (The RTX operation system is used in the program.)

 

ftm_config_t ftmInfo;
ftm_chnl_pwm_signal_param_t ftmParam[BCR_LED_CHANNEL_NUMS];

/* Configure the FTM module for LED1 & LED2 */
ftmParam[0].chnlNumber = (ftm_chnl_t)BCR_LED_GRP1_FTM_CH1;
ftmParam[0].level = kFTM_LowTrue;
ftmParam[0].dutyCyclePercent = 0U;
ftmParam[0].firstEdgeDelayPercent = 0U;

ftmParam[1].chnlNumber = (ftm_chnl_t)BCR_LED_GRP1_FTM_CH2;
ftmParam[1].level = kFTM_LowTrue;
ftmParam[1].dutyCyclePercent = 0U;
ftmParam[1].firstEdgeDelayPercent = 0U;

FTM_Type *base = BCR_LED_GRP1_FTM_BASEADDR;
FTM_GetDefaultConfig(&ftmInfo);
ftmInfo.prescale = kFTM_Prescale_Divide_4;
FTM_Init(base, &ftmInfo);
FTM_SetupPwm(base, ftmParam, BCR_LED_CHANNEL_NUMS, kFTM_EdgeAlignedPwm, BCR_FTM_PWM_FREQUENCEY, BCR_FTM_SOURCE_CLOCK);
FTM_StartTimer(base, kFTM_SystemClock);
FTM_EnableInterrupts(base, kFTM_TimeOverflowInterruptEnable);

/* Configure the FTM module for LED3 & LED4 */
ftmParam[0].chnlNumber = (ftm_chnl_t)BCR_LED_GRP2_FTM_CH1;
ftmParam[0].level = kFTM_LowTrue;
ftmParam[0].dutyCyclePercent = 0U;
ftmParam[0].firstEdgeDelayPercent = 0U;

ftmParam[1].chnlNumber = (ftm_chnl_t)BCR_LED_GRP2_FTM_CH2;
ftmParam[1].level = kFTM_LowTrue;
ftmParam[1].dutyCyclePercent = 0U;
ftmParam[1].firstEdgeDelayPercent = 0U;

base = BCR_LED_GRP2_FTM_BASEADDR;
FTM_GetDefaultConfig(&ftmInfo);
ftmInfo.prescale = kFTM_Prescale_Divide_4;
FTM_Init(base, &ftmInfo);
FTM_SetupPwm(base, ftmParam, BCR_LED_CHANNEL_NUMS, kFTM_EdgeAlignedPwm, BCR_FTM_PWM_FREQUENCEY, BCR_FTM_SOURCE_CLOCK);
FTM_StartTimer(base, kFTM_SystemClock);
FTM_EnableInterrupts(base, kFTM_TimeOverflowInterruptEnable);

NVIC_EnableIRQ(BCR_LED_GRP1_FTM_IRQn);
NVIC_EnableIRQ(BCR_LED_GRP2_FTM_IRQn);

 

Best Regards,

Huiqi Li

Outcomes