Need Help with UART configuration


On the BeagleBone Black I’m using UART4 for my application.

When I check the UART4 TxD output with the Oscilloscope I’m getting confusing results. Maybe I’m sending the data over UART wrongly, hopefully somebody can help me.

At the beginning I do: stty -F /dev/ttyO4 raw

afterwards I expect the logic to be standard. With 1 HIGH and 0 LOW

But when I do it on BBB for 1 (HIGH) i get

root@beaglebone:~# echo 1 > /dev/ttyO4

root@beaglebone:~# echo 0 > /dev/ttyO4

root@beaglebone:~# echo 110 > /dev/ttyO4

root@beaglebone:~# echo 010 > /dev/ttyO4

root@beaglebone:~# echo 11111111 > /dev/ttyO4

Is it possible to have a normal digital logic as the output of UART? If yes, how to do so.


ascii for “1” is 00110001
ascii for Line feed is 00001010

so you will get
d0 = 1
d1 = 0
d2 = 0
d3 = 0
d4 = 1
d5 =1
d6 = 0
d7 =0
sp = 1
st = 0
d0 = 0
d1 = 1
d2 = 0
d3 = 1
d4 - d7 =0
sp = 1
idle = 1

Hello Rod,

Thanks you for the help on this, was really helpful.
But do you know how can I send the binary instead of ascii? (Do I need to put maybe prefix of SB before the value to send binary?)

After many unsuccessful attempts of sending binary over UART, I’m looking at possibility to change the UART MODE described in TI AM335x ARM A8 Microprocessors technical reference manual , maybe this will allow me to send the binary then.

For my project, the transceiver that I wan to connect to UART needs CMOS/TTL logic.

I’m really not sure this question at all. UART4 Tx a single wire which is high by default. Put a multimeter on the uart4tx pin to confirm this. If you send data to it then it goes out in blocks of N bits (N normally being 10 - start bit, 8 data bits, stop bit), then returns to the default state of high until the next transmission.

Do you want to send binary data bit-by-bit, as in: write 1 to it, the pin goes high, write 0 and the pin goes low? Then that’s not what a UART does - sounds like GPIO to me.

Do you want to send the byte 0, as in: start bit, 8 x low bits, stop bit? Then “echo -n \x00 > /dev/ttyO4” should do it. But much easier to do this in C (or any other language) as the ttyO4 is just a file: open it, set it up as a TTY (in C with functions tcsetattr, cfmakeraw etc), then write the zero byte to the stream.

Hi Mike,

I want to send the string of binary data, like 10001111 or 11110011 etc., and I expect to see HIGH and LOW on Oscilloscope.

When I use command set “echo -n \x01 > /dev/ttyO4” i can see on oscilloscope
“echo -n \x1001 > /dev/ttyO4”

It is still in ascii, is there a way how to get it to work and send standard binary string , because my device needs CMOS/TTL logic.

It’s the shell causing your problems, not the UART. First, it should be

“echo -n \x00 > /dev/ttyO4”

Two backslashes (my error, sorry). Second, “man echo” and take a look at the syntax, you can’t just do “\xNNNNNNNNN”. To repeat, you should really write some software to do this rather than doing it from the shell.

Thanks again,

Yes, I know I need to write a software, I initially wanted to check the method of sending the data over the UART on shell and then write the software to do the same thing.

I suppose it’s not the best way to include the: system (“echo … > /dev/ttyO4”), call in the software, as it’s the shell that causes the problems for me.

Can you maybe suggest the best way how I should address the UART in my software, I haven’t seen any examples for the UART programming using c/c++ on beaglebone online.


Just google linux serial programming. BBB is no different to any other Linux (or indeed UNIX) box in this respect - here’s one for started: