Deadtime insertion for KE06 FTM2

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

Deadtime insertion for KE06 FTM2

727 Views
yinyang
NXP Employee
NXP Employee

Hi 

            I tried to insert the deadtime when using KE06 FTM2 PWM, it's not successfully.

            I used the sample code frdmke06z_driver_examples_ftm_pwm_twochannel_ftm_pwm_twochannel

            I modfied     config->deadTimeValue = 32; in the FTM_GetDefaultConfig(ftm_config_t *config) function

and called FTM_SetDeadTimeEnable(BOARD_FTM_BASEADDR,(ftm_chnl_t)BOARD_FIRST_FTM_CHANNEL,1);

            I noticed that the register  FTMx_DEADTIME is written protected, and can be on written when 

MODE[WPDIS] = 1.  I'm not sure whether the value is properly written.

            Can you provide a working example for the deadtime control insertion?

Labels (1)
0 Kudos
3 Replies

579 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Yin Yang,

   I don't what the FRDM-KE06 code you are using, I have checked the FRDM-KE06 official driver, you can use this code to add the deaddtime:

void FTM_PWMDeadtimeSet(FTM_Type *pFTM, uint8_t u8PrescalerValue, uint8_t u8DeadtimeValue)
{
    ASSERT(FTM2 == pFTM);
    
    pFTM->COMBINE |= 0x101010;              /* enable dead time insertion */

    if(!(pFTM->MODE & FTM_MODE_WPDIS_MASK)) /* if write protection is enabled */
    {
        pFTM->MODE |= FTM_MODE_WPDIS_MASK;  /* disable the write protection */
        pFTM->DEADTIME = (FTM_DEADTIME_DTVAL(u8DeadtimeValue & 0x3F) | FTM_DEADTIME_DTPS(u8PrescalerValue & 0x3));
        pFTM->MODE &= ~FTM_MODE_WPDIS_MASK; /* enable the write protection */       
    }
    else
    {
        /* if no protection */
        pFTM->DEADTIME = (FTM_DEADTIME_DTVAL(u8DeadtimeValue & 0x3F) | FTM_DEADTIME_DTPS(u8PrescalerValue & 0x3));
    }
    pFTM->SYNC |= FTM_SYNC_SWSYNC_MASK;     /* software sync */

Official KE series driver can be downloaded from this link:

FRDM-KEXX Driver Library Package

Wish it helps you!


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

579 Views
yinyang
NXP Employee
NXP Employee

Hi Kerry, 

          I download the SDK from MCUXpresso frdmke06z. This function you mentioned above is not included in the drivers.

          So which one are the official KE drivers? 

0 Kudos

579 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Yin Yang,

   Both SDK and the KE driver which I recommend you are our official code.

   SDK for KE driver is just published, I just find it.

   But don't worry, after compare the code with the FTM_PWMDeadtimeSet which I give you, you can find, before you use the KE sdk FTM_SetDeadTimeEnable, yo ualso need to disable the write protection:

static inline void FTM_SetWriteProtection(FTM_Type *base, bool enable)
{
    /* Configure write protection */
    if (enable)
    {
        base->FMS |= FTM_FMS_WPEN_MASK;
    }
    else
    {
        base->MODE |= FTM_MODE_WPDIS_MASK;
    }
}

Then you call the FTM_SetDeadTimeEnable function again, you will find the dead time can be used.

You can try it on your side.

If you still have question after you try it, please kindly let me know.


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos