Not sure where to put this question, so in the FAQ it goes.
I am working on a project where the uController reads serial data from a device at 4800 bps but then in turn must write to an LCD serial display at at least 9600 bps. Independently, I can get both devices to work with my Arduino, but if I try and read the serial device at 4800, process the data, then change the serial speed to 9600 to write to the LCD I get corrupted text.
Is it possible to change the serial speed during execution (say in the void loop() function) or am I doing really bad things? Maybe I need to pause execution just after changing serial speed to give the uC time to catch up? Flush the buffer as well?
Don’t have an answer to your question, but did you consider using software serial to write to the LCD?
software serial is good for relatively slow, write-only applications. (I’m assuming you don’t read from the LCD.)
Maybe you could use the “normal” serial port on the Arduino board to communicate with the 9600 device.
And use the “soft serial” (see the playground for inf. on this) to communicate with the 4800 device
EDIT : Arrgh i didn’t read the other reply properly before answering the same
Just an update on this problem for future reference.
Turns out changing the serial speed is fine. I programmed in a 5 millisecond delay after changing the speed but I am not even sure if that is needed. My problem with corrupted data being transmitted (and it is corrupted in transmission, not during receiving) seems to only occur when sending serial data down the USB port to the arduino software. Data sent to the LCD display is fine. Temporarily unplugging the LCD display did not fix the problem, so the LCD acting as a “load” does not interfer with sending serial data down the USB.
By the way, this is with the NG board. Since my app will not need sending data down the USB connection the problem is fine for me, but I wonder why data is being corrupted.