I'm trying to use SCT peripheral for a simple PWM output.
I started from lpcxpresso54628_sctimer_simple_pwm SDK example project for EVB OM13098 and it works, I saw 24kHz PWM with 50% duty-cycle.
I made the following changes:
- commented out the second call of SCTIMER_SetupPwm() to avoid conflicts with the first
- changed counter mode from kSCTIMER_CenterAlignedPwm to kSCTIMER_EdgeAlignedPwm
- changed duty-cycle to 20%
Again it works, I saw 24kHz PWM signal with a 20% duty-cycle.
Now I changed duty-cycle to 0% and I expcted to see a static low level signal. However the output signal isn't always low, it shows a very short glitch. It is short, because SCT counts at a frequency of 220MHz and I suspect the glitch duration is a clock tick (4.5ns).
Just to further investigate, I changed the prescaler from 0 (default) to 99 (clock divided by a factor of 100). Now I can see the "glitch" as a 450ns pulse.
So the question is: how to have a true 0% duty-cycle (static low-level signal) with SCT in kSCTIMER_EdgeAlignedPwm mode?
There are some comments in SDK code:
/* Calculate pulse width and period match value:
* For EdgeAlignedPwm, "pulsePeriod = 0" results in 0% dutycyle, "pulsePeriod = period - 1U" results in 100% * dutycyle. For CenterAlignedPwm, , "pulsePeriod = 0" results in 0% dutycyle, "pulsePeriod = period + 2U"
* results in 100% dutycyle.
*/
However it appears this is wrong.