change baudrate UART to custom value

852 views
Skip to first unread message

steinma...@gmail.com

unread,
Nov 7, 2014, 2:29:50 PM11/7/14
to beagl...@googlegroups.com
Is it possible to change the baud rate of the UART to a custom value like 100.000 bits/s?
In the datasheet of the AM335x Sitara the different modes are:
2.4 Kbps
9.6 Kbps
19.2 Kbps
38.4 Kbps
57.6 Kbps
115.2 Kbps

But I read on this forum that they did set the baud rate to 500k.

The library that I use (libbulldog) doens't support custom baudrates, and this one makes use
of the termios.h (which also doesn't support other baudrates).

Does anyone know how to change the baud rate to a custom value? I need this because I want 
to read a bus from a commercial product which works on 100.000 bits/s. (SBus from Futaba).

I am new to programming microcontrollers, so my knowledge of setting registers etc. is limited.

kind regards,
Stein

steinma...@gmail.com

unread,
Nov 15, 2014, 2:23:28 PM11/15/14
to beagl...@googlegroups.com
The AM335x Sitara processor has two registers, divisor high and divisor low, where you can set the preferred divisor.
With the formula 'baudrate = clock / (over sampling x divisor)' you can calculate the divisor for the desired baudrate.
There are 2 modes, 16x and 13x, for the over sampling. I will use the 16x mode.
I want to have a baudrate of 100 kbps, so my divisor needs to be 30. This gives an error of 0%.
You can find information about these registers at page 4270 in the datasheet of the AM335x

Does anyone know how I can set these registers?

kind regards, 
Stein

Steve French

unread,
Nov 16, 2014, 12:37:01 AM11/16/14
to beagl...@googlegroups.com
Stein,
I am in the same boat!!  I need to set the UART to 250k baud for DMX512 lighting.  According to your below math, this should be 16x oversampling and a divisor of 12 for me.
I hope there is a way to set these values via command line and/or config files.

This stuff here is interesting, but I'm not sure how (or if) I can change these numbers?
debian@vBBB20:/sys/devices/ocp.3/481a8000.serial/tty/ttyO4$ ls
close_delay   custom_divisor  device  iomem_base       io_type  line  power      type     uevent
closing_wait  dev             flags   iomem_reg_shift  irq      port  subsystem  uartclk  xmit_fifo_size
debian@vBBB20:/sys/devices/ocp.3/481a8000.serial/tty/ttyO4$ sudo cat uartclk
48000000
debian@vBBB20:/sys/devices/ocp.3/481a8000.serial/tty/ttyO4$ sudo cat custom_divisor
0

Looks interesting, but not sure how to manipulate these things?  Device Tree?  DTC?  Config files?
I am watching this thread closely now.  Thx!
-frenchy

berg...@gmail.com

unread,
Oct 2, 2015, 3:05:28 PM10/2/15
to BeagleBoard
DId you guys have any luck? I need to get 250k working on a beaglebone black as well
Reply all
Reply to author
Forward
0 new messages