Need some help to set up one FTM Ch to be able to output constant 50% DC PWM, with at run time variable frequency.
Target; 1Hz - 500Hz
Using SDK, S32K144.
Any suggestions?
Thank you!
/ Chris
Hi Chris J
There is already an example that can do this in the SDK that comes with the S32DS, you can find it as ftm_pwm_s32k144. Please check it and don't hesitate to tell me if you have any question about it.
Have a great day,
TIC
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
-------------------------------------------------------------------------------
Hi Jorge!
I have looked into this example and as far as i can see it is set up to
I have tried to use the FTM_DRV_UpdatePwmPeriod() function to just change the period/frequency and keep the DC at 50%.
But I seeing some trouble to keep a clean 50%DC while changing period. I think I have some kind of timer sync problem..?
Hi Chris J
You have to update the Duty cycle too, because it has to be recalculated with every change in the period, so you need something like:
FTM_DRV_UpdatePwmPeriod(INST_FLEXTIMER_PWM1, FTM_PWM_UPDATE_IN_TICKS, new_period, true);
FTM_DRV_UpdatePwmChannel(INST_FLEXTIMER_PWM1, 0U, FTM_PWM_UPDATE_IN_DUTY_CYCLE, 0x4000U, 0U, true);
Hope this helps
Regards