I successfully run the SDK sctimer_pwm_with_dutycycle_change example program on the MCX-N5XX-EVK board. I successfully changed the PWM mode from Center-Aligned to Edge-Aligned.
But I get the following issues:
- The SCT outputs a short high impulse when I set 0% duty cycle.
- The SCT outputs a short low impulse when I set 100% duty cycle.
- In addition to the dudty cycle, I also need to change the PWM frequency run-time, so I tried to re-configure the PWM with my following function:
short PWM_FreqSet( unsigned long pwmFreq_Hz, unsigned char duty)
{
short RetVal = 0;
sctimer_pwm_signal_param_t pwmParam;
uint32_t sctimerClock = SCTIMER_CLK_FREQ;
/* Stop the 32-bit unify timer */
SCTIMER_StopTimer(SCT0, kSCTIMER_Counter_U);
/* Configure PWM with the new frequency */
pwmParam.output = DEMO_SCTIMER_OUT;
pwmParam.level = kSCTIMER_HighTrue;
pwmParam.dutyCyclePercent = duty;
if (SCTIMER_SetupPwm(SCT0, &pwmParam, kSCTIMER_EdgeAlignedPwm, pwmFreq_Hz, sctimerClock, &eventNumberOutput) == kStatus_Success)
{
RetVal = 1;
/* Start the 32-bit unify timer */
SCTIMER_StartTimer(SCT0, kSCTIMER_Counter_U);
}
return RetVal;
}
But it does not work, although SCTIMER_SetupPwm() returns kStatus_Success. And, after the first calling to my PWM_FreqSet() function, the PWM timer does not work any more, I need to reset my board to recover it.
How to fix those issues on SCTIMER?