Mega2560 Baudrate doubled

When I set a baudrate on the MEGA2560 to - for example - 19200 the communication with PC is 38400. I had this error weeks befor, then (after library update) it worked correct and now (after new library update) I have the same problem. I tryed to modify HardwareSerial.cpp to set clear u2x mode, but it does not change anything.

OK, its not a big fault, but it is annoying...

Thanks for tips!

u2x mode should be accounted for already; the issue you are describing doesn't happen to anyone else and should not be occurring. It is likely symptomatic of a deeper issue; usually this implies that the sketch is compiled for a different clock speed than the chip is actually running at.

Is timing in general working correctly on the board? Does blink blink at the right speed?

Does the sketch you're using have anything else going on, or is it just a test of serial?

What board are you using, and with what version of the IDE? Is it a custom board, maybe with a custom third party board package that is set to run at 8mhz when the hardware has a 16mhz one?

It is an Arduino MEGA R3 Board from open-source electronics running at 16MHz. The IDE is 1.8.1.

The funny problem is, that it happened when I reloaded the same code to the board. Before reloading all was OK after reprogramming the baudrate was doubled.

I tried it with a new board → double baudrate!
Closing IDE, starting new and reprogramming → double baudrate
Rebooting the PC → same result

I can not understand why this can happen.

Are there some fuses which are set wrong?

Thanks for ideas.

Hi, What happens if you load a simple bit of code that just serial prints numbers to the monitor?

Tom.... :)

Here is my code for testing:

unsigned long nexttime = 0;

void setup() { Serial.begin(19200); Serial.println("READY"); }

void loop() { if (millis() - nexttime > 1000) { nexttime = millis(); Serial.println(millis()); } }

To view output in Serial Monitor: Baudrate 38400!!!

What is wrong?

Hi, It works at 19200 on my mega, strange.

You might need to bring this problem up in another part of the forum more suited to hardware faults.

Tom.. :)

After installing IDE 1.8.5 it works correct!!!

I try to get out what´s the difference.

Thanks for help!

MWSoft:
After installing IDE 1.8.5 it works correct!!!

I try to get out what´s the difference.

Thanks for help!

No problem, my IDE 1.8.3.
Tom… :slight_smile:

I wonder if you modified the boards.txt entry for the Mega in the previous installation at some point and forgot? If you still have your old IDE version installed you could compare the two build.f_cpu values.