KSDK2.0 FTM PWM setup bug

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

KSDK2.0 FTM PWM setup bug

873 Views
mtbrewster
Contributor I

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.

Labels (1)
0 Kudos
3 Replies

561 Views
Jmart
NXP Employee
NXP Employee

Mike -

I've forwarded on your finding to the FTM developer.

Regards

0 Kudos

561 Views
manfredschnell
Contributor IV

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

0 Kudos

561 Views
bluetiger9
Contributor II

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));