That's true, there is a mistake into the code i did post, sorry about it!
Anyway; here is the point:
this code produce a signal on pin 11 but not on pin 3;
see the Table 18-6. in the 328p doc, wich restrict the use of OC2B
#define CntValue 16000000 / 560 / 128
void setup()
{
pinMode(3, OUTPUT);
pinMode(11, OUTPUT);
TCCR2B = 0; // Stop timer2
TCNT2 = 0; // Clear timer2 counter
TCCR2B = _BV(WGM22); // Fast PWM mode, TOP = OCR2A; Prescaler = No Clock
TCCR2A = _BV(WGM21) | _BV(WGM20) | _BV(COM2A0) | _BV(COM2B0);
OCR2A = CntValue; // Set timer2 TOP value
TCCR2B = _BV(WGM22) | _BV(CS22) | _BV(CS20); // Enable timer2, divide-by-128 prescale
}
void loop()
{
// listen the hp
}
I did test this code right now, arduino uno.
This is for PWM mode.
In Compare Output Mode,
there is an odd thing :
WGM22 = 0: Normal Port Operation, OC2A Disconnected.
WGM22 = 1: Toggle OC2A on Compare Match.
You cannot activate 0C2A if WGM22 isn't set, but you can set OC2B to be toggling in both conditions.
This forbide a few uses for both OC2B and OC2A.