PWM in FRDMK64

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

PWM in FRDMK64

跳至解决方案
1,731 次查看
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.

标签 (1)
0 项奖励
回复
1 解答
1,380 次查看
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!
-----------------------------------------------------------------------------------------------------------------------

在原帖中查看解决方案

1 回复
1,381 次查看
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!
-----------------------------------------------------------------------------------------------------------------------