Hello Pablo Cosgaya,
I have checked the functionality of the FTM outputs on the target board and I have found the problem with the PWM mode. The SetupPWM() function support just the Combine PWM mode but the Complementary PWM mode must be set for proper functionality of the deadtime insertion. Currently, the complementary mode and deadtime insertion is supported by the following inline functions in the ftm driver:
/*!
* @brief This function enables/disables complementary mode in a channel pair.
*
* @param base FTM peripheral base address
* @param chnlPairNumber The FTM channel pair number; options are 0, 1, 2, 3
* @param value true: enable complementary mode; false: disable complementary mode
*/
static inline void FTM_SetComplementaryEnable(FTM_Type *base, ftm_chnl_t chnlPairNumber, bool value)
/*!
* @brief This function enables/disables the dead time insertion in a channel pair.
*
* @param base FTM peripheral base address
* @param chnlPairNumber The FTM channel pair number; options are 0, 1, 2, 3
* @param value true: Insert dead time in this channel pair; false: No dead time inserted
*/
static inline void FTM_SetDeadTimeEnable(FTM_Type *base, ftm_chnl_t chnlPairNumber, bool value)
Therefore the same polarity of the FTM channels must be used (e.g. .chnlPolarity = 0), see the FTM configuration below:
const ftm_config_t FTM_1_config = {
.prescale = kFTM_Prescale_Divide_1,
.bdmMode = kFTM_BdmMode_0,
.pwmSyncMode = kFTM_SoftwareTrigger,
.reloadPoints = 0,
.faultMode = kFTM_Fault_Disable,
.faultFilterValue = 0,
.deadTimePrescale = kFTM_Deadtime_Prescale_16,
.deadTimeValue = 20,
.extTriggers = 0,
.chnlInitState = 0,
.chnlPolarity = 0,
.useGlobalTimeBase = false
};
And the FTM initialization function must be updated by the following way:
void FTM_1_init(void) {
FTM_Init(FTM_1_PERIPHERAL, &FTM_1_config);
FTM_SetupPwm(FTM_1_PERIPHERAL, FTM_1_combinedPwmSignalParams, sizeof(FTM_1_combinedPwmSignalParams) / sizeof(ftm_chnl_pwm_signal_param_t), kFTM_CombinedPwm, 10000U, FTM_1_CLOCK_SOURCE);
FTM_SetComplementaryEnable(FTM_1_PERIPHERAL, kFTM_Chnl_0, true);
FTM_SetDeadTimeEnable(FTM_1_PERIPHERAL, kFTM_Chnl_0, true);
FTM_SetComplementaryEnable(FTM_1_PERIPHERAL, kFTM_Chnl_1, true);
FTM_SetDeadTimeEnable(FTM_1_PERIPHERAL, kFTM_Chnl_1, true);
FTM_StartTimer(FTM_1_PERIPHERAL, kFTM_SystemClock);
}
I have already proposed the updated of the ftm driver to support the complementary mode (including the deadtime insertion) in the FTM_SetupPWM(), FTM_SetupPwmMode() and FTM_UpdatePwmDutycycle() functions. Subsequently the FTM component shall be also updated to support the Complementary mode and deadtime insertion.
Best Regards,
Marek Neuzil