Problem with serial interface

Hi, I have uploaded this sketch to my Arduino Mega2560 R3: http://pastebin.com/75p96kqC Everytime I change the baud to anything higher than 9600 and connect via Hterm to the device it writes back "FO" multiple times, at least at 115200baud With other rates this output changes (Yes, i have set the rates in Hterm and sketch to the same value.)

This behaviour does not appear in the loop-back test (http://arduino.cc/forum/index.php/topic,73748.0.html)

Is this a known problem? Can it be fixed?

Its not a known problem as far as I know. The crystal or resonator could be defective and off frequency causing errors at high baud rates.

Did you mean to use "Serial.print()" instead of "Serial.write()"?

[quote author=James C4S link=topic=87566.msg657560#msg657560 date=1326854031] Did you mean to use "Serial.print()" instead of "Serial.write()"? [/quote]

I did not send anything to the arduino. Serial.available() should always be 0. => no output

smeezekitty: Its not a known problem as far as I know. The crystal or resonator could be defective and off frequency causing errors at high baud rates.

mh... this would mean that the rest of the communication is affected too (right?). But the garbage is only sent immediately after starting the connection.

I’m not too surprised. I tend to get a few garbage bytes at the start of running a sketch. It’s an unavoidable side-effect of the USB interface not being sure what baud rate you are running at.

You could wait a few milliseconds and then discard any input you have so far.