PWM in FRDMK64

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

PWM in FRDMK64

Jump to solution
1,133 Views
deeptimoodliar
Contributor II

I am new to PWM using FTM. I have worked a bit on KSDK 1.3.0 and FRDMK64F board.

In K64 certain gpio pins can be configured as dedicated PWM pins as per manual.

However, there is no specific example of PWM generation on a pin with a specific period and duty cycle available in KSDK 1.3.0.

In demo_apps there is bubble_level_ftm, but it is not using the PWM pin and neither generating a prefixed duty cycle.

I just want to generate pulses on PWM pin of a desired period and duty cycle.

I thought the following flow of functions was good enough:

 

hardware_init();

OSA_Init();

configure_ftm_pins(FTM0_IDX);

 

CLOCK_SYS_EnableFtmClock(BOARD_FTM_INSTANCE);

ftmParam.mode               = kFtmEdgeAlignedPWM;
ftmParam.edgeMode           = kFtmLowTrue;
ftmParam.uFrequencyHZ       = PWM_FREQ_HZ;
ftmParam.uDutyCyclePercent  = 50;
ftmParam.uFirstEdgeDelayPercent = 0;

 

// Enable FTM module and generate PWM
memset(&ftmInfo, 0, sizeof(ftmInfo));
ftmInfo.syncMethod = kFtmUseSoftwareTrig;

 

FTM_DRV_Init(BOARD_FTM_INSTANCE, &ftmInfo);
FTM_DRV_SetClock(BOARD_FTM_INSTANCE, kClock_source_FTM_SystemClk, kFtmDividedBy1);
FTM_DRV_PwmStart(BOARD_FTM_INSTANCE, &ftmParam, BOARD_FTM_CHANNEL);

 

But this is not working. Kindly let me know where I am wrong.

Labels (1)
0 Kudos
1 Solution
782 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi Deepti,

please refer if this article with demo code can help you:

Rainbow color using FTM PWM with KSDK 1.3


Have a great day,
Jennie Zhang

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

View solution in original post

1 Reply
783 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi Deepti,

please refer if this article with demo code can help you:

Rainbow color using FTM PWM with KSDK 1.3


Have a great day,
Jennie Zhang

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