Configuring serial for arbitrary non-standard baud rates?

This forum is for users of Microchip MPUs and who are interested in using Linux OS.

Moderator: nferre

jdupre
Location: Petaluma, California
Posts: 44
Joined: Sat Apr 16, 2005 12:47 am

Configuring serial for arbitrary non-standard baud rates?

Wed Jun 01, 2005 11:48 pm

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
dwight
Location: Silicon Valley
Posts: 14
Joined: Thu Jun 02, 2005 5:02 pm

Thu Jun 02, 2005 10:20 pm

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?
ulf
Location: Sweden
Posts: 134
Joined: Wed Feb 18, 2004 5:53 pm

Sat Jun 04, 2005 8:06 am

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.
Best Regards
Ulf Samuelsson
dwight
Location: Silicon Valley
Posts: 14
Joined: Thu Jun 02, 2005 5:02 pm

Sat Jun 04, 2005 4:51 pm

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.

Return to “LINUX”

Who is online

Users browsing this forum: Baidu [Spider], Google [Bot] and 2 guests