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
Hi,
I'm sorry but it seems you didn't upload any picture.
You can try to monitor the CnV or MOD or other related register to see if there is any unexpected modify to these register.
There is a camera like icon at the top of reply area. Click it can insert image.
Regards,
Jing
Hi Jing:
Thanks for your reply. Actually I compared the FTM0 to FTM3, but no obvious mistake found.
It seems there is a periodical high level output, are there any registers specific relevant to this kind of output?
Here is a picture of error PWM output. Please check.
Best Regards,
Huiqi
Hi,
It seems your code is similar to the ftm_pwm_twochannel demo. I couldn't find any problem from your code. There is also no such a error report in errata. Since FTM3 is a copy of FTM0, you can compare their registers value in each interrupt.
Regards,
Jing
Somehow I can't upload a 35KB picture. Do you know how to upload? Thanks.
Any comments? I need help. Thanks.