SDK 2.0 PWM configuration, ¿bug?

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

SDK 2.0 PWM configuration, ¿bug?

Jump to solution
1,122 Views
anthonyLoren
Contributor II

Hi, I've been working with SDK 2.0 for kinetis MK22FA12..  

In the archive fsl_ftm.c it seems to be a bug when configuring PWM (high-true or low true selection).

The result of this:

reg &= ~(FTM_CnSC_MSA_MASK | FTM_CnSC_MSB_MASK | FTM_CnSC_ELSA_MASK | FTM_CnSC_ELSB_MASK);

reg |= (FTM_CnSC_ELSA(chnlParams->level) | FTM_CnSC_ELSB(chnlParams->level));

when level is kFTM_HighTrue (2U)

is always ELSA = ELSB = 0,  i.e. 00 

 

down below, in the same file there is another line that looks better:

reg |= ((uint32_t)chnlParams->level << FTM_CnSC_ELSA_SHIFT) & (FTM_CnSC_ELSA_MASK | FTM_CnSC_ELSB_MASK);

 

Is this ok or I'm missing something ?

 

Thanks in advance.

Labels (1)
Tags (1)
0 Kudos
Reply
1 Solution
895 Views
ivadorazinova
NXP Employee
NXP Employee

Hi Antonio.

Yes, this was a bug which was already fixed in latest release.

The root cause about code is that, the type for “chnlParams->level”, “ftm_pwm_level_select_t”,  is defined as:

/*! @brief FTM PWM output pulse mode: high-true, low-true or no output */
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 value of enum item is also the mask for the two bits field (FTM_CnSC_ELSA_MASK and FTM_CnSC_ELSB_MASK), in previous version you have

reg |= (FTM_CnSC_ELSA(chnlParams->level) | FTM_CnSC_ELSB(chnlParams->level));

 

Then we fixed it and changed to use the current one, which is corrected now.

            /* Setup the active level */
            reg |= (uint32_t)(chnlParams->level << FTM_CnSC_ELSA_SHIFT);‍‍

So, I recommend you download the latest version KSDK (which is available now) or for quick fix (but not a good way) replace this part of code.

Best Regards,

Iva

View solution in original post

2 Replies
896 Views
ivadorazinova
NXP Employee
NXP Employee

Hi Antonio.

Yes, this was a bug which was already fixed in latest release.

The root cause about code is that, the type for “chnlParams->level”, “ftm_pwm_level_select_t”,  is defined as:

/*! @brief FTM PWM output pulse mode: high-true, low-true or no output */
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 value of enum item is also the mask for the two bits field (FTM_CnSC_ELSA_MASK and FTM_CnSC_ELSB_MASK), in previous version you have

reg |= (FTM_CnSC_ELSA(chnlParams->level) | FTM_CnSC_ELSB(chnlParams->level));

 

Then we fixed it and changed to use the current one, which is corrected now.

            /* Setup the active level */
            reg |= (uint32_t)(chnlParams->level << FTM_CnSC_ELSA_SHIFT);‍‍

So, I recommend you download the latest version KSDK (which is available now) or for quick fix (but not a good way) replace this part of code.

Best Regards,

Iva

895 Views
anthonyLoren
Contributor II

Hello Iva:

after building a new sdk for this configuration: SDK_2.0_MK22FN1M0Axxx12 / SDK 2.0 / KDS / Windows . 

It seems to have the same fault code,  like the former one. 

Is that the right way to get the newest SDK version ?

Best regards

0 Kudos
Reply