Problem with using Timer at atmega 2560

Hello :)!
I am new to Arduino, I have been using AVR studio for compiling and programming of Atmega 2560. Recently I have been moved to Arduino, the issue which I am facing is that I wasn't able to use 2 or 3 output compare match in one-timer. For example, I am using 16-bit timer 3, but I can't use both of its A and B at the same time, maybe I have been doing in the wrong way at Arduino. As at AVR studio 7, this type of code runs smoothly and doesn't give any issue. The issue I am facing as when I assign Timer 3 some value then after onward again assign some value to it to enable its second B output it overwrites the first one and i didn't get anything at the output of OCR3A. the only output I was getting was at OCR3B. basically I am generating a 50hz PWM signal using timer 3. Any Help would be highly appreciated. Kindly stick to machine code not get into libraries etc. Thanks. The code is attached.

void setup() {

pinMode(5,OUTPUT);
pinMode(2,OUTPUT);

//Timer 3-A
TCCR3A = 0x82; //TCCR3A |= (1<<WGM31)|(0<<WGM30)|(1<<COM3A1)|(0<<COM3A0);
TCCR3B = 0x12; //TCCR3B |= (1<<WGM33)|(0<<WGM32)|(1<<CS31)|(0<<CS30);
ICR3 = 20000;

//Timer 3-B
TCCR3A = 0x22; //TCCR3A |= (1<<WGM31)|(0<<WGM30)|(1<<COM3B1)|(0<<COM3B0);
TCCR3B = 0x12; //TCCR3B |= (1<<WGM33)|(0<<WGM32)|(1<<CS31)|(0<<CS30);
ICR3 = 20000;
}

void loop() {

OCR3A=1000;

OCR3B=1500;
}

The issue I am facing as when I assign Timer 3 some value then after onward again assign some value to it to enable its second B output it overwrites the first one and i didn't get anything at the output of OCR3A. the only output I was getting was at OCR3B.

That's because you are replacing the first setting with the second use of TCCR3A =.

Use |= when adding the second output and wanting to preserve the existing settings.

void setup() {
  Serial.begin(115200);  
  TCCR3A = 0x82;
  //TCCR3A = 0x22;
  TCCR3A |=0x22;
  Serial.println(TCCR3A,BIN);
}
void loop() {
}

Thank You so much for your precious time. Now the code works fine.