Page 1 of 1

Configuring serial for arbitrary non-standard baud rates?

Posted: Wed Jun 01, 2005 11:48 pm
by jdupre
The AT91RM9200 and other hardware support many different clock rates for the USARTs. However, it appears that the Linux serial driver and common utilities like stty only support the "standard" baud rates (9600, 38400, 115200, etc.) for serial devices.

How do I go about setting up a serial port in Linux to support an arbitrary, non-standard rate?

Am I going to have to write my own serial driver to enable "custom" baud rates?

- Joe

Posted: Thu Jun 02, 2005 10:20 pm
by dwight
No, you don't have to write your own custom driver for this. But why in the world would you want to set up your own custom baud rates?

Posted: Sat Jun 04, 2005 8:06 am
by ulf
dwight wrote:No, you don't have to write your own custom driver for this. But why in the world would you want to set up your own custom baud rates?
Because some protocols like MIDI run at a non standard BAUD rate.

Posted: Sat Jun 04, 2005 4:51 pm
by dwight
Wow, one learns something new every day! :) Thanks for the clarification.

Ok, there are two possible approaches which come to mind then. The first is to change the clock rate on the chip. The second is to make a small modification to serial driver.

I'll caveat this with saying that I don't have the board you do; this is just a general UNIX/Linux principle which has been around since the dawn of time.

Basically, the stty flag settings for c_cflag (E.g. B9600, B19200, etc), get mapped from ther termios structure into a divisor setting for the serial chip. It's this last value which programs the chip with the baud rate.

So all you have to do is to change this value to that of what your chip will support. You could even set up an IOCTL to do this if you wanted.

If your chip only supports standard baud rates, then your only option will be to change the clock frequency appropriately.

I hope that helps.