slag in the PWM signal with TIMER2

Hello,

I don't understand , in PWM waveform on Arduino's pin 11 (ATMega328P's output OC2A), i find some pulses per group of 5 while 0 is placed in the OCR2A register. Every pulse is 64µs widht, 180ms between pulses group, .
This doesn't happen with the other 2 TIMERs and this doesn't happen, either, in "Phase-Correct PWM" mode for the 3 TIMERs.

Can anyone help me understand this phenomenon?

Here the program which gives PWM signal in pin 11:

void setup() {
  pinMode(11, OUTPUT);
}

void loop() {
 
// Mode Fast PWM
  TCCR2A = _BV(COM2A1) | _BV(COM2B1) | _BV(WGM21) | _BV(WGM20);
  TCCR2B = _BV(CS22) | _BV(CS21) | _BV(CS20); // /1024
  OCR2A = 0;
}

Sorry for my bad english. I hope you understand what i mean.

Without digging into this very deeply, I am a bit curious about your setting those registers over and over at high speed in loop(). Usually you set a mode and leave it alone except for the PWM match register.

This:

your setting those registers over and over at high speed in loop()

is the PROBLEM.

The data sheet has specific warnings about setting registers like OCR2A.

It is rarely useful to put a zero in an OCRnx register.

Tank you for your answers.

You right AARG i alway forget the [while (1); ] at the end of the routine. But after correct it’s the same.

@JREMINGTON: The data sheet says [If the OCR2A is set equal to BOTTOM, the output will be a narrow spike for each MAX+1 timer clock cycle.]. I don’t have a narrow spike but a group of 5 narrow spikes every 180ms.
My PWM drive a RGB LED and it’s necessary to have 0 <= OCR2A <= 255.
I have this problem in Fast PWM mode and not in Phase correct PWM mode.

I just wanted to know why by curiosity because i shall program in Phase correct PWM mode and i won’t have any more problem.

I don't have a narrow spike but a group of 5 narrow spikes every 180ms.

It has been pointed out twice why that is happening.

fefer:
You right AARG i alway forget the [while (1); ] at the end of the routine. But after correct it's the same.

Then you didn't correct it properly. Please post the latest code with the changes you made. I suggest moving the setup code to the setup() function instead of putting while(1)'s anywhere.

void setup() {
  pinMode(11, OUTPUT);
}

void loop() {
 
// Mode Fast PWM
  TCCR2A = _BV(COM2A1) | _BV(COM2B1) | _BV(WGM21) | _BV(WGM20);
  TCCR2B = _BV(CS22) | _BV(CS21) | _BV(CS20); // /1024
  OCR2A = 0;
while(1);
}

I don't put "while(1);" anywhere. It is at the end.