FTM0 clock configuration problem

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

FTM0 clock configuration problem

581 Views
leandro_f_rocco
Contributor III

Hi, I am using MCUXpresso IDE and FRDM-K64F board.

I am trying to configure four PWM channels using FTM0 at a frequency of 50hz. My definitions are the following:

#define FTM_SOURCE_CLOCK CLOCK_GetFreq(kCLOCK_McgFixedFreqClk)

#define FTM_MODULE FTM0
#define PWM_CH0 0U
#define PWM_CH1 1U
#define PWM_CH2 2U
#define PWM_CH3 3U

And my configuration code is the following:

    ftm_config_t ftmInfo;
    ftm_chnl_pwm_signal_param_t ftmParam[4];

    ftmParam[0].chnlNumber = (ftm_chnl_t)PWM_CH0;
    ftmParam[0].level = kFTM_HighTrue;
    ftmParam[0].dutyCyclePercent = 5U;
    ftmParam[0].firstEdgeDelayPercent = 0U;

    ftmParam[1].chnlNumber = (ftm_chnl_t)PWM_CH1;
    ftmParam[1].level = kFTM_HighTrue;
    ftmParam[1].dutyCyclePercent = 5U;
    ftmParam[1].firstEdgeDelayPercent = 0U;

    ftmParam[2].chnlNumber = (ftm_chnl_t)PWM_CH2;
    ftmParam[2].level = kFTM_HighTrue;
    ftmParam[2].dutyCyclePercent = 5U;
    ftmParam[2].firstEdgeDelayPercent = 0U;

    ftmParam[3].chnlNumber = (ftm_chnl_t)PWM_CH3;
    ftmParam[3].level = kFTM_HighTrue;
    ftmParam[3].dutyCyclePercent = 5U;
    ftmParam[3].firstEdgeDelayPercent = 0U;

    FTM_GetDefaultConfig(&ftmInfo);
    FTM_Init(FTM_MODULE, &ftmInfo);
    FTM_SetupPwm(FTM_MODULE, ftmParam, 4U, kFTM_EdgeAlignedPwm, 50U, FTM_SOURCE_CLOCK);
    FTM_StartTimer(FTM_MODULE, kFTM_FixedClock);

My problem is that the definition FTM_SOURCE_CLOCK is equal to 32552, but looking at my clock settings, the value of FTM_SOURCE_CLOCK should be 390625.

Below, is my clocks configurations.  Can you help me with this problem?

Thanks.

clock1.jpg

clock2.jpg

Labels (1)
0 Kudos
1 Reply

463 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Leandro Fabián Rocco ,

I test on my side, configure the MCGFFCLK to 390.625KHZ, then get the freq using:

 CLOCK_GetFreq(kCLOCK_McgFixedFreqClk);

the result is the same with Config tool:

pastedImage_2.png

pastedImage_1.png

You can send your project to me, I will help to check it .

Hope it helps,


Have a great day,
TIC

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

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos