It appears there is a bug in the KSDK2.0 driver for the FTM in the FTM_SetupPwm function. It has to do with specifying the output type, the ELSnB:ELSnA settings in the CnSC register. The input parameter is ftm_chnl_pwm_signal_param_t *chnlParams. The level field in that struct is an enum of type ftm_pwm_level_select_t which has possible values of:
typedef enum _ftm_pwm_level_select
{
kFTM_NoPwmSignal = 0U, /*!< No PWM output on pin */
kFTM_LowTrue, /*!< Low true pulses */
kFTM_HighTrue /*!< High true pulses */
} ftm_pwm_level_select_t;
The error is in the following line of code (which is used in both branches of if/else):
/* Setup the active level */
reg |= (FTM_CnSC_ELSA(chnlParams->level) | FTM_CnSC_ELSB(chnlParams->level));
this shifts level by 2 and masks it with 4 and ORs that with level shifted by 3 anded with 8.
This does not give the appropriate ELSnB:ELSnA settings.
Mike -
I've forwarded on your finding to the FTM developer.
Regards
Hi Jason,
I need a PWM with kFTM_HighTrue, too.
Did you get any reaction from FTM developer Team?
In the meantime I use Attilas workaround.
Best regards.
Manfred
This is still not fixed.
Ugly fix for who needs high-true PWM:
/* Setup the active level */
reg |= chnlParams->level == kFTM_HighTrue ? 8
: (FTM_CnSC_ELSA(chnlParams->level) | FTM_CnSC_ELSB(chnlParams->level));