Arduino Mega 2560 error.

When runnnig "Arduino Mega Example" code at https://www.arduino.cc/en/Serial/Begin

// Arduino Mega using all four of its Serial ports 
// (Serial, Serial1, Serial2, Serial3), 
// with different baud rates:

void setup(){
  Serial.begin(9600);
  Serial1.begin(38400);
  Serial2.begin(19200);
  Serial3.begin(4800);

  Serial.println("Hello Computer");
  Serial1.println("Hello Serial 1");
  Serial2.println("Hello Serial 2");
  Serial3.println("Hello Serial 3");
}

void loop() {}

.. the message "Hello Computer" is displayed at 9600 bauds on Serial Monitor At 38400 bauds the Terminal shows "€xxxøxøxøx€ø" At 19200 bauds Terminal shows "€˜fžàžþž" And instead of "Hello Serial 3" it shows "¼­˜þ¿>ø" when 4800 bauds are selected.

Should I suspect of a severe malfunction on the behaviour of the board?

How did you connect the other ports to the computer. RS232 converter?

Did you adjust the baudrate on the Serial Monitor (or other terminal program that you use)?

Thanks for your reply…
I simply connect the USB cable from PC to Mega 2560. No other devices are used.
I use Arduino arduino IDE 1.6.7 and after loading the code I mentioned I open the serial monitor window on PC and select the baud rates corresponding to the listed on sketch.
I only get the correct reading on the 9600 case (“Hello computer”). When the other rates are selected (for Serial 1/2 or 3) the text does not correspond with the “Hello Serial 1, 2 or 3” as it should…
I´m running this sketch due to random failures observed each time I try to use these extra serial ports on this board.
I can´t find an exhaustive routine on the web to check those ports… Somethng like a “diagnostic” to check deeply the communications area on this board.
I´m sure that SDA/SDL ,included in the area, are working OK.
I´m not an expert in software but have experience on hardware… And normally, the interface Processor/Pheripherals is treated in a single circuit block. So… it confuses me the normal work on SDA/SDL and failures on the other pins of the “COMMUNICATION” area…
Thanks again…

I forgot to mention…
No matter the times I´ve run the sketch, the results (even without readable) are exactly the same for each baud rate selected on the serial monitor.
Thus meake me think, that what I call “reading errors”, are NOT ramdom errors… as they keep the same result…
As I said in previous post, a more exhaustive test could determine what´s goin on…

I don't have a Mega, but as far as I know Serial 1/2/3 are TTL outputs, not USB outputs. So how do you connect those? As far as I know, you need a special cable; I think it's called FTDI but not sure.

If you connected the Mega pins directly to the computer, you have the wrong signal levels and your data is inverted. That can explain the behaviour.

Serial 1,2,3 are on different pins. Only Serial goes to the on-board usb serial adapter. So you were seeing the message it was sending at 9600, at the wrong baud rate so you saw gibberish, while the other messages were sent to pins with nothing connected to them.

The other ports are for connecting to other devices. To see them on a computer you must use another usb serial adapter.

"Serial 1,2,3 are on different pins. " ..... On Mega 2560 and related literature, pins 19/18 is Serial 1, 16/17 Serial 2 and 14/15 Serial 3.... What other pins?..

Hello again.. Considering Serial1, Serial 2 and serial 3 on Mega 2560.. Installing a jumper on Serial 1,from pin 19 to 18 (Tx -->Rx) ...or jumper on Serial 2, from pin 16 to 17 (Tx -->Rx) ...or jumper on Serial 3, from pin 14 to 15 (Tx -->Rx) One at a time or all at once... Is it possible to write a test routine to test them?

Yep

Send something on Serial1 and read it back. Whatever was read back can be send via Serial to a terminal program.

Something in the line of

//send some data
Serial1.print("Hello");
// if data available on the same port
while(Serial1.available >0)
{
  // read it back from the same serial port
  // and echo to Serial
  Serial.write(Serial1.read);
}
Serial.println(" ===> DONE");

But you still have not explained how you wired everything to get the odd results.

I think I explained before... I simply connect the Mega with the usb connector to the laptop. No sensors, no jumpers,... Just the Mega 2560, and run the routine on 1st. Post I'll try the code on your last post. Thanks a lot sterretje

PD...A question about code on your post: Should I jumper Serial1 pins 19 and 18 before run?

With the routine of the first post you will not get anything from Serial1/2/3. Serial1/2/3 are not connected to the USB on the board.

I think this is what happened:
You set serial monitor, baudrate 9600 and you see correct information.
Next you change the baudrate of the serial monitor and you see corrupt information.

If so, that is because you only see Serial and that is communicating at 9600; changing that baudrate of the serial monitor will give garbled data. You will see the same result if you take the Serial1/2/3 out of your code and do the same exercise (changing baudrates).

sterretje: With the routine of the first post you will not get anything from Serial1/2/3. Serial1/2/3 are not connected to the USB on the board.

I think this is what happened: You set serial monitor, baudrate 9600 and you see correct information. Next you change the baudrate of the serial monitor and you see corrupt information.

If so, that is because you only see Serial and that is communicating at 9600; changing that baudrate of the serial monitor will give garbled data. You will see the same result if you take the Serial1/2/3 out of your code and do the same exercise (changing baudrates).

So.... I can assume everything is OK on Serial1/2/3 serial ports?..

Last one question: Running your code I get

error: 'Serial1' does not name a type

No idea sbout the error, never used a Mega. Just add it to the code that you posted, in the loop().

And yes, you should jumper.

pacheco: error: 'Serial1' does not name a type

Did you put Serial1.begin(xxxx); in setup?

Post the code your using.