Duty cycle configuration in code

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

Duty cycle configuration in code

739 Views
rahul_eris
Contributor II

We  are using KDS 3.0.0 and ksdk 1.2.0

We need to generate pwm output with different dutycycles given in code.

we used fsl_ftm component for pwm

But the dutycycle remains same,( means the one which we give at the time of code generation using processor expert.)

 

 

 

Can anyone  help me to overcome this problem.

 

64731_64731.pngpastedImage_1.png

 

 

64742_64742.pngpastedImage_3.png

64732_64732.pngpastedImage_2.png

Labels (1)
Tags (2)
0 Kudos
2 Replies

470 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi,

if we don't use KSDK, we can use PPG component that includes method to change PWM duty cycle.

However, fsl_ftm component  doesn't contain any option or method to update PWM duty cycle. this issue will be solved in KSDK1.3.0 which is target to be released at the end of Q3.

There is the PWMStart method only. You can use the FTM_HAL_SetChnCountVal() method of the HAL driver but you must also ensure the proper synchronization of the CnV register (e.g. use the FTM_HAL_SetSoftwareTriggerCmd()).

this issue was also discussed her:

https://community.freescale.com/message/496961

can this answer help you?


Have a great day,
Zhang Jun

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

0 Kudos

470 Views
rahul_eris
Contributor II

Hi,

Now I can update the PWM Duty cycle in code by the below codes....Also can able to run multiple channels with that fsl_ftm component(FTM0)

FTM_DRV_Init(FSL_FLEXTIMER1,&flexTimer1_InitConfig0);

FTM_DRV_CounterStart(FSL_FLEXTIMER1,kCounting_FTM_UP, 0, 0xFFFF, false);

flexTimer1_ChnConfig0.uDutyCyclePercent=50;                                                                 //vary the duty cyce of channel 1

FTM_DRV_PwmStart(FSL_FLEXTIMER1,&flexTimer1_ChnConfig0,3U);

flexTimer1_ChnConfig1.uDutyCyclePercent=90;                                                                //  vary the duty cyce of channel 2

FTM_DRV_PwmStart(FSL_FLEXTIMER1,&flexTimer1_ChnConfig1,1U);

FTM_HAL_SetSoftwareTriggerCmd(FTM0_BASE_PTR, true);

Thanks

0 Kudos