I am experiencing a strange behavior of the PWM signal during ramping of the duty cycle value on my LM4F232H5QD board. My PWM generators are running at 20 kHz in synchronized mode, and I am updating their duty cycles every 250 us (4 kHz), the PWM period is 4000. When I do a ramp of the duty cycle from MIN (0) to MAX (3999), the output signal looks very strange towards the end. In the attached image the purple signal is the duty cycle, the green signal indicates that my duty cycle counter wraps around to zero again, and the turquoise signal is the PWM output lowpass filtered.
I would expect the PWM output to go from completely off (0) to 100% (at 3999) when I ramp the duty cycle. What I do not really understand is
1) Why is the PWM signal still 100% after my counter wraps around and starts counting from zero?
2) Why is there one PWM period of 0% duty cycle? The duty cycle is updated just before it dips, and then the PWM signal goes 100%-0%-100% before the next update.