Hi all,
I’m implementing an interface to a commercial product that communicates over an asynchronous interface at 62500 Baud. Looking at the <termios.h> files on the BBB I cannot find this setting. Is it at all possible to set up a u(s)art to communicate at this speed? Is it possible with ioctl()? Where can I find more info on the later ?
Thanks for your replies.
On Tue, 10 Oct 2017 09:04:48 -0700 (PDT), Paul Van den Bergh
<vdbergh.paul@gmail.com> declaimed the
following:
Hi all,
I'm implementing an interface to a commercial product that communicates
over an asynchronous interface at 62500 Baud. Looking at the <termios.h>
files on the BBB I cannot find this setting. Is it at all possible to set
up a u(s)art to communicate at this speed? Is it possible with ioctl()?
Where can I find more info on the later ?
The TI Technical Reference Manual for the SoC used by the BBB. (Page
4320 of SPRUH73P http://www.ti.com/lit/ug/spruh73p/spruh73p.pdf
Baud rate Over sampling Divisor Error (%)
300 16 10000 0
600 16 5000 0
1200 16 2500 0
2400 16 1250 0
4800 16 625 0
9600 16 313 0.16
14400 16 208 0.16
19200 16 156 0.16
28800 16 104 0.16
38400 16 78 0.16
57600 16 52 0.16
115200 16 26 0.16
230400 16 13 0.16
460800 13 8 0.16
921600 13 4 0.16
1843200 13 2 0.16
3000000 16 1 0
3686400 13 1 0.16
No 62500... No MIDI 31250 either <G>
It might be possible to program one of the PRUs to emulate a UART at
the needed speed. (Unless I stuffed a few too many zeros in it, I'm coming
up with over 3000 PRU instructions per bit <G>)
Hi Denis,
Thanks for your reaction.
In <termios.h> the same baudrates as in your post are mentioned. However, after googling about the topic I’m now investigating in the ioctl() function. For the moment I have this in my code:
`
/*
Hi all,
I'm implementing an interface to a commercial product that communicates
over an asynchronous interface at 62500 Baud. Looking at the <termios.h>
files on the BBB I cannot find this setting. Is it at all possible to set
up a u(s)art to communicate at this speed? Is it possible with ioctl()?
Where can I find more info on the later ?
Thanks for your replies.
Read Peter Hurley's second post. From he link below. He he wrote / linked
code that will do any baud rate. A gist on github I believe it is. Then
it's just a gcc -Wall <filename.c> -o <whatever you want to call the
https://groups.google.com/forum/#!searchin/beagleboard/serial$20baud$20rate$205760|sort:relevance/beagleboard/GC0rKe6rM0g/13c1ngXF7owJ
On Tue, 10 Oct 2017 10:23:50 -0700 (PDT), Paul Van den Bergh
<vdbergh.paul@gmail.com> declaimed the
following:
Hi Denis,
Thanks for your reaction.
In <termios.h> the same baudrates as in your post are mentioned. However,
after googling about the topic I'm now investigating in the ioctl()
function. For the moment I have this in my code:
<SNIP>
This compiles without errors or warnings. But before I can test it I have
to investigate in the "never ending story of device tree overlays".
I don't think it will help. Compiling/linking shouldn't be a concern --
all the arguments are literals/constants. It is run-time when the driver
does the configuration that will likely return some errno value (probably
EINVAL).
At the lowest level, any baud setting by ioctl() has to configure the
hardware UART clock/dividers, and the driver is likely limited to the
values documented in the TRM.
BTW I cannot use one of the PRUSS processors because they are both used for
other purposes.
Going to insane concepts now:
Time to plug in an Arduino (Mega and Due have 4 HW UART, Uno only has
one and uses a software emulated UART for others) programmed as a
serial<>serial baud rate converter <G> {SoftwareSerial only supports
standard rates; the hardware is implied to support non-standard: "You can,
however, specify other rates - for example, to communicate over pins 0 and
1 with a component that requires a particular baud rate."}
http://wormfood.net/avrbaudcalc.php?bitrate=65200&clock=16&databits=8
{applies to Uno; Due is not an AVR chip}
Or maybe the BBPocket to use one of its PRUs programmed as a UART with
non-standard baud rate with the regular UART talking to the BBB on a
standard rate. <G>
Going to insane concepts now:
I am faced with this situation just because I need to communicate with an AVR device running @ 10MHz. This 10MHz is required to produce RS485 signals @ 62500 baud. However, at a clock rate of 10MHz I’m unable to generate ‘standard’ baud-rates as they are available in Linux. I can’t change the RS485 baud rate (Products on the market). Furthermore my prototype pcb’s are on the way…
(see also http://www.avrfreaks.net/forum/avr-usart-baudrates#comment-2292516)

Hi folks,
Finally, I succeeded in resolving this problem:
`
struct termios2 settings;
m_fdSerial = open(m_pDevice.c_str(), O_RDWR | O_NOCTTY);
if(m_fdSerial < 0)
{
// TODO Daemon has no terminals, use syslog
perror(“open”);
}
int r = ioctl(m_fdSerial, TCGETS2, &settings);
if®
{
perror(“ioctl”);
}
settings.c_ispeed = settings.c_ospeed = 62500;
settings.c_cflag &= ~CBAUD;
settings.c_cflag |= BOTHER;
r = ioctl(m_fdSerial, TCSETS2, &settings);
if®
{
perror(“ioctl”);
}
while(1)
{
write(m_fdSerial, “U”, 1);
}
`
Running this code an the BBB (after enabling the uart1 overlay) gives this output:

This is exactly what was needed. 