Pages: [1]   Go Down
Author Topic: Changing serial speed  (Read 638 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 3
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Everyone!

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?

Thanks

Nomadiq.
Logged

0
Offline Offline
Faraday Member
**
Karma: 8
Posts: 2526
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.)

-j

Logged

Copenhagen / Denmark
Offline Offline
Edison Member
*
Karma: 6
Posts: 2360
Do it !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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 :-)
« Last Edit: January 19, 2008, 05:53:01 am by MikMo » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 3
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Cheers,

Nomadiq
Logged

Pages: [1]   Go Up
Jump to: