which Pin belongs to which COM?

Hi there,

I am trying to understand the operations made on this code.
I think I am understandig what it´s doing after searching for a while in the datasheet.

pinMode(3, OUTPUT);
pinMode(11, OUTPUT);
TCCR2A = _BV(COM2A1) | _BV(COM2B1) | _BV(WGM21) | _BV(WGM20);
TCCR2B = _BV(CS22);
OCR2A = 180;
OCR2B = 50;

But I don´t understand the relation between COM2A1 and COM2B1 to its pins.
Where from do I know, which compare register relates to which output pin.
Same here when setting the Dutycycle:

OCR2A = 180;
OCR2B = 50;

So I don´t know exactly the pin of which options I have changed.

Does someone know where I can find the relations in the datasheet?
I am using the arduino nano with the Atmega 328P, her the datasheet:
http://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-8271-8-bit-AVR-Microcontroller-ATmega48A-48PA-88A-88PA-168A-168PA-328-328P_datasheet_Complete.pdf
Thanks!!!

anneme:
Does someone know where I can find the relations in the datasheet?
I am using the arduino nano with the Atmega 328P, her the datasheet:

The Pin Configuration diagram near the top of the datasheet shows the functions of every pin. For example 0C2A is pin 17 and 0C2B is pin 5.

Then you need to look up the Arduino pin mapping to link the physical numbers with the Arduino I/O pin numbers. Physical pin 5 is Arduino pin 3 and physical pin 17 is Arduino pin 11

...R

Those mysterious labels are registers and bit positions within the register. Each register will refer to a memory location and each bit position will map [7:0]. Get this datasheet and look at ch. 35 for an overview.

Where registers are physical as well, there is a one-to-one mapping and the pin name used in the datasheet is the used as a physical reference. For pin mapping reference, its useful to have a pinout diagram for the board you are using. These are available all over everywhere on the net. I’ve attached on for the Nano for convenience.

Nano.pdf (196 KB)

anneme:
Where from do I know, which compare register relates to which output pin.

The following diagram may help you to find the answers of your queries around NANO Board.

Thanks for your answers,

that datasheet were kind of more clear to me.

Actually I am generating the PWM-Signal with the analogWrite() Funktion and I am getting strange results in my output.

Do you know if the analogWrite() function is compatible with fast PWM-mode on Pin 11?

anneme:
Do you know if the analogWrite() function is compatible with fast PWM-mode on Pin 11?

The analogWrite(arg1, arg2); is a customized Arduino Function which has very specific/limited functionalities. This function is used to generate known-frequency (490Hz, 490Hz, 980Hz) and variable ON-period (with only 8-bit resolution) PWM signals on known DPins of UNO as depicted in Fig-1.

The arg1 of the anaogWrite() function refers to the DPins (3, 11, 10, 9, 5, 6) and arg2 is an 8-bit value that determines the ON-period of the Signal. arg2 supports flexible addressing modes like reading the analog pin, map it, and then putting it in place of arg2. For example: (analogWrite (3, map(analogRead(A0), 0, 1023, 0, 255));.

If you want to generate high frequency PWM signal with 10/12/more bit resolution, you need to create sketch that manipulates the contents of TCx's registers.
pwm328xy.png
Figure-1; PWM signals generated by analogWrite() function

pwm328xy.png