Is it possible to reset pwm?

I am using a servo signal to control a speed controller. Sending a new value to the motor depends on the repeat frequency of the pwm pulse. I want to eliminate the waiting time that occurs when the new value is available and the pwm is busy sending a pulse out.

pwm in mode 14 on timer 1 with a prescaler of 8
OCR1A defines the pulse width at 5000 (2 ms)
ICR defines the repeat frequency at 50000 (20 ms)

What I want my code to do is to reset the pwm out as soon as this is possible.

Can this work?

while (TCNT1<7500) // wait a minimum of one ms after sending a pulse { ;; } OCR1A = newValue; TCNT1 = 0;

If this works it would save me 17 ms in transmitting the newValue to the ESC

This is a tricky situation, so see the timer section of the ATmega328 data sheet for a detailed answer. If incorrectly configured the timer can temporarily get “stuck” with the output pin in an inappropriate on or off state, leading to output glitches. So, the target PWM value (OCRx) is double buffered and under most but not all conditions, the timer hardware doesn’t update that value immediately.

You were right, setting the timer to 0 will stop the output pulse. But if you give it a little time to do the normal housekeeping it works like a dream. I reduced the waiting period and made the timer counter to jump to 500 ticks before the end. This assures a minimum of 1ms between pulses.

while (TCNT1<7000) // wait a minimum of one ms after sending a pulse { ;; } OCR1A = newValue; TCNT1 = ( ICR1 - 500); // jump to the end but leave some time for housekeeping