Diferance hardware serial ports on the Arduino Mega2560 ESP-01 & Due

Hi, my friends,
I use hardware serial to communicate with ESP - and also to flashing firmware its simple code - but work perfect on Arduino Due....

#define Serial_ESP Serial3
#define Serial_Debug Serial
// definicje pinów
int CH_PD_8266 = 18; //CH PIN High normall work
int RST = 12; // Reset HIGH normal work
int Flashing = 11; // PIN GPIO0 when flashing LOW

void setup()
{
Serial_ESP.begin(115200);
Serial_Debug.begin(115200);
pinMode(CH_PD_8266, OUTPUT);
pinMode(RST, OUTPUT);
pinMode(Flashing, OUTPUT);
digitalWrite(RST, HIGH);
digitalWrite(CH_PD_8266, HIGH );
delay(50);
digitalWrite(Flashing, LOW);
}

void loop()

{
if (Serial_ESP.available()) {
Serial_Debug.write(Serial_ESP.read());
}
Serial_Debug.flush();

if (Serial_Debug.available()) {
Serial_ESP.write(Serial_Debug.read());
}
Serial_ESP.flush();
}

I try use it with Mega - of course I need level logic voltage change to 3.3 and I use for it MC74HC541ADTG.... it working - I can send data to ESP and take to me from ESP

And now - if I flash ESP - can't comunicate with module :frowning: Why ? on Due working exeletnt ..Is on MEGA2560 is some diference with hardware serial?

Try setting the pins to the right mode/position before activating Serial.begin

Hi J-M-L thanks for answer - replace declaration nothing change
I think the problem is in hardware TX RX pins...
I use all version ESP8266 Flash Download Tools (old and new) - allways i have information

(True, )
test running : False
serial port opened
Connecting...
chip sync error.
com closed

I made short GPIO0 to GND ( without software) and nothing - with DUE as programer TX->TX3, RX-RX3 and ftdi programer - I can flash without any problems - MEGA 2560 has something bad in serial ports...

Before I thiink that problem is in Logic Level Converter 5v->3v3 - I made examp with resistor for down voltage - and nothing change - same problem

Any help or solution for check?