Hello,
In MK60DN256VLL10, I'm trying to generate 25MHz PWM with 50% duty cycle (using 50MHz external clock) in Edge aligned mode. System clock and Core clock = 100MHz and Bus Clock = 50MHz.
According to the reference manual, FTM period in edge aligned mode = (MOD - CNTIN + 0x1) and duty cycle = (CnV - CNTIN). So, to generate 25MHz, MOD must be 1, CNTIN must be 0 and CnV must be 1.
When I set these manually, I do see 25MHz PWM being generated on the scope.
However, the SDK/MCUXpresso cannot seem to set CnV correctly for this condition. I think issue seems to be in the code below in fsl_ftm.c (exists in more than 1 place).
........................
mod = base->MOD;
if ((currentPwmMode == kFTM_EdgeAlignedPwm) || (currentPwmMode == kFTM_CenterAlignedPwm))
{
cnv = (mod * dutyCyclePercent) / 100;
/* For 100% duty cycle */
if (cnv >= mod)
{
cnv = mod + 1;
}
base->CONTROLS[chnlNumber].CnV = cnv;
}
........................
In our case, mod = 1 and dutyCyclePercent = 50. So, cnv remains 0. We want cnv to be 1, I think.
Please let me know if I'm configuring FTM improperly. If you can generate 25MHz PWM using external 50MHz clock via MCUXpresso, please let me know the FTM configuration . I tried various settings via the Peripheral tool of MCUXpresso but was unsuccessful. For now, I have hacked the fsl_ftm.c code and got it to work. If it is a bug in SDK, please plan to fix it in the next revision as soon as possible.
Regards,
Satish
Thank you for the report, I'll inform the SDK team about this.
Sorry for the inconvenience we bring you!
Best Regards,
Robin