While working on a project dealing with parsing ascii strings, I noticed some odd behavior when using the Serial object. When using Serial.read to read in strings, repeated characters led to unexpected, but repeatable, results. For example, sending the string 555 resulted in 55ë.
More specifically:
Sending ascii 555 to a chip running this:
void loop()
{
character = Serial.read();
Serial.print( character );
}
resulted in output that looks like this:
55ë
Has anyone else experienced this? Can anyone repeat the bug? Am I missing something?
I was using hyperterminal to send ascii characters at 9600 baud to a max232 chip, which was connected to the RX arduino pin. The TX pin was sending ascii characters and was hooked up to a sparkfun serial lcd. Unfortunately I can't paste the sketch because of an n.d.a...
Hmm, I would try splitting up the different tasks to see which one (if it's only one) that's the problem. Out of curiosity why are you using the Max chip instead of the builtin USB or serial connection on the Arduino board? Can you try simply echoing the characters back to the computer to see if the problem is in the communication with the LCD or the computer?
I used a max232 because I was receiving rs232 line signals and needed to convert them to TTL level signals to send into the arduino serial port. So, I actually did use the arduino serial port after the incoming rs232 signal was converted to the proper signal for the atmel chip.
I tried several different debug methods (echo to computer, to lcd, to memory, etc...) and determined the bug was software based.
It's certainly possible that the problem is in the Arduino software. Can you give us more details about the communication? Are you seeing a problem when you send just the three characters "555"? Do you see 55ë every time you send those characters? What if you send other three character strings? Longer or shorter strings?
I've seen this sort of problem with the software serial on Arduino, but the hardware serial seems to reasonably reliable, so if you get an incorrect character when you only send 3 bytes, I suspect it has something to do with the setup (not that it's wrong, but just that it's making different assumptions than the Arduino software does). Is it possible there's a mismatch between the serial settings that the Arduino is using (8-bit, no parity, one stop bit, no flow control) and those that HyperTerminal is using?