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:
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.
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.
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.