Author Topic: changing serial baud rate  (Read 8482 times)

Offline neil

  • Sr. Member
  • ****
  • Posts: 438
    • View Profile
changing serial baud rate
« on: November 07, 2008, 09:34:03 PM »
Hi Mark,
  I have the 52233 serial port connected to a multiplexer so I can address 8 serial devices on the same port. All works well, and all operatore at 9600 baud. I now have one device connected to the multiplexer that requires 2400 baud . How can I change the baud rate between transfers? I assume I will have to clear the tx buffer before doing so.

Best Regards
Neil

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3237
    • View Profile
    • uTasker
Re: changing serial baud rate
« Reply #1 on: November 07, 2008, 10:33:45 PM »
Hi Neil

To change the serial mode (on-the-fly) you can use the technique used by fnSetNewSerialMode() in application.c.

Basically the serial interface is configured by opening the first time using
fnOpen( TYPE_TTY, FOR_I_O, &tInterfaceParameters );

Then by calling again with
fnOpen( TYPE_TTY, MODIFY_CONFIG, &tInterfaceParameters );

causes it to be reconfigured.

It is of course best not to change while it is in the middle of sending something. You can also call the flush function
fnFlush(SerialPortID, FLUSH_RX);
fnFlush(SerialPortID, FLUSH_TX);

(note that rx and tx have to be flushed separately) to ensure that the buffers are really empty.
See also:
http://www.utasker.com/forum/index.php?topic=327.0
and
http://www.utasker.com/forum/index.php?topic=345.0


Regards

Mark