AnsweredAssumed Answered

PWM in FRDMK64

Question asked by Deepti Moodliar on Feb 15, 2016
Latest reply on Feb 16, 2016 by ZhangJennie

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.

Outcomes