PWM in FRDMK64

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 
1,787件の閲覧回数
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,436件の閲覧回数
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,437件の閲覧回数
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!
-----------------------------------------------------------------------------------------------------------------------