Need Help with UART configuration

452 views
Skip to first unread message

Andrei

unread,
Nov 21, 2013, 5:44:50 AM11/21/13
to beagl...@googlegroups.com
Hello

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.










rod calabio

unread,
Nov 25, 2013, 3:05:16 PM11/25/13
to beagl...@googlegroups.com
Andrei

   ascii for "1"  is 00110001
   ascii for Line feed is 00001010

  so you will get 
   st=0
   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 

Andrei

unread,
Nov 26, 2013, 9:42:46 AM11/26/13
to beagl...@googlegroups.com
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. 

Mike Bremford

unread,
Nov 26, 2013, 1:53:44 PM11/26/13
to beagl...@googlegroups.com
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. http://en.wikipedia.org/wiki/Asynchronous_start-stop

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. 


--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Andrei

unread,
Nov 27, 2013, 4:42:03 AM11/27/13
to beagl...@googlegroups.com
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.  

Mike Bremford

unread,
Nov 28, 2013, 12:35:51 PM11/28/13
to beagl...@googlegroups.com
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.

Andrei Kondratjev

unread,
Nov 29, 2013, 4:51:03 AM11/29/13
to beagl...@googlegroups.com
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.

Thanks


You received this message because you are subscribed to a topic in the Google Groups "BeagleBoard" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/beagleboard/ytnqeNF6gik/unsubscribe.
To unsubscribe from this group and all its topics, send an email to beagleboard...@googlegroups.com.

Mike Bremford

unread,
Nov 29, 2013, 5:00:05 AM11/29/13
to beagl...@googlegroups.com
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: http://tldp.org/HOWTO/Serial-Programming-HOWTO/index.html.
Reply all
Reply to author
Forward
0 new messages