AnsweredAssumed Answered

Combined_PWM problem using FTM + KSDK 2.0

Question asked by shaul dorf on Sep 3, 2016
Latest reply on Sep 19, 2016 by shaul dorf

The test is based on NXP community “https://community.nxp.com/thread/428308”: <SDK_2.0_MK64FN1M0xxx12>\boards\twrk64f120m\driver_examples\ftm\pwm_twochannel.

My test board is FRDM-K64F and Software KDS 3.2 + KSDK v2.0.

 I modified this example to test three PWM’s operation modes: edge, center and combined.

The first two are working O.K.

With the third (combined) is a problem, there is no PWM output.

Looking in “EmbSys Registers” debugger window the CnV registers are zero (no configuration).

When I configured those registers directly FTM output behavior was as expected.

 

Is there any problem with the ….. , kFTM_CombinedPwm, … API or something is missing in my attached program?

 

 

       // Init board hardware.

       BOARD_InitPins();

       BOARD_BootClockRUN();

       BOARD_InitDebugConsole();

 

       // Add your code here

       ftm_config_t ftmInfo;

       ftm_chnl_pwm_signal_param_t ftmParam[4];

 

       FTM_GetDefaultConfig(&ftmInfo);

 

// Configure ftm params with frequency 24kHZ

 

       ftmParam[0].chnlNumber = (ftm_chnl_t)Channel_0;

       ftmParam[0].level = kFTM_LowTrue;

       ftmParam[0].dutyCyclePercent = 10U;

       ftmParam[0].firstEdgeDelayPercent = 10u;

 

       ftmParam[1].chnlNumber = (ftm_chnl_t)Channel_1;

       ftmParam[1].level = kFTM_LowTrue;

       ftmParam[1].dutyCyclePercent = 40U;

       ftmParam[1].firstEdgeDelayPercent = 40u;

 

       ftmParam[2].chnlNumber = (ftm_chnl_t)Channel_2;

       ftmParam[2].level = kFTM_LowTrue;

       ftmParam[2].dutyCyclePercent = 50U;

       ftmParam[2].firstEdgeDelayPercent = 50u;

 

       ftmParam[3].chnlNumber = (ftm_chnl_t)Channel_3;

       ftmParam[3].level = kFTM_LowTrue;

       ftmParam[3].dutyCyclePercent = 90U;

       ftmParam[3].firstEdgeDelayPercent = 90u;

 

 

/* Initializes the FTM module. */

       FTM_Init(FTM_BASEADDR, &ftmInfo);

 

/* Mode Select */

       // Edge     Aligned PWM

//     FTM_SetupPwm(FTM_BASEADDR, ftmParam, 4U, kFTM_EdgeAlignedPwm, 1000U, FTM_Clock_src);

       // Center   Aligned PWM

//     FTM_SetupPwm(FTM_BASEADDR, ftmParam, 4U, kFTM_CenterAlignedPwm, 1000U, FTM_Clock_src);

       // Combined Aligned PWM

       FTM_SetupPwm(FTM_BASEADDR, ftmParam, 4U, kFTM_CombinedPwm, 1000U, FTM_Clock_src);

 

/* Complementary Enable */

       FTM_SetComplementaryEnable(FTM_BASEADDR, 0,1);

//     FTM_SetComplementaryEnable(FTM_BASEADDR, 1,1);

//     FTM_SetComplementaryEnable(FTM_BASEADDR, 2,1);

//     FTM_SetComplementaryEnable(FTM_BASEADDR, 3,1);

 

       /* Direct CnV configuration n=0, 1, 2, 3 */

       FTM0->CONTROLS[0].CnV=0x1000;

       FTM0->CONTROLS[1].CnV=0x4000;

       FTM0->CONTROLS[2].CnV=0x5000;

       FTM0->CONTROLS[3].CnV=0xc000;

 

       FTM_StartTimer(FTM_BASEADDR, kFTM_SystemClock);

 

 

Thanks,

Shaul

Outcomes