Hello Tiva community,
I am having a problem with my TM4C123GH6PM controller when I try to apply a new PWM period (i.e new frequency of the output of the PWM) instantly. The scenario is that we are running the PWM with an output frequency of 100 Hz and then we want to instantly change the output frequency to 100kHz without delay. The problem is that the PWM waits until the counter comes back to zero before applying the new frequency, which is too long for us when the counter has a frequency of 100Hz(that we need to have in the initial state).
The solution we have tried is to reset the counter which should apply the new settings immediately, but unfortunately it did not work. We have the PWM configured as "PWMGenConfigure(PWM0_BASE, PWM_GEN_0, PWM_GEN_MODE_DOWN |PWM_GEN_MODE_DBG_RUN| PWM_GEN_MODE_NO_SYNC | PWM_GEN_MODE_GEN_NO_SYNC );" and below is how we have tried to change the frequency of the PWM:
PWMSyncTimeBase(PWM0_BASE, PWM_GEN_0_BIT); // resets the timer to zero
PWMGenPeriodSet(PWM0_BASE, PWM_GEN_0, cycle_time);
PWMPulseWidthSet(PWM0_BASE, PWM_OUT_0, 5);
PWMSyncUpdate(PWM0_BASE, PWM_GEN_0_BIT); // updates the period change next time the timer hits zero
PWMSyncTimeBase(PWM0_BASE, PWM_GEN_0_BIT); // resets the timer to zero
When looking at an oscilloscope capturing when we send the command to change frequency and capturing the actual PWM output we still get a delay of 0.01 sec at most which is the time it takes for the counter to come back to zero at 100Hz, which is too long and we want to decrease the delay by a factor of 10 at least.