Personal tools

Log in

Changes

From IGEP - ISEE Wiki

Jump to: navigation, search

How to use UARTs

10 bytes added, 12:27, 22 August 2012
m
no edit summary
= Overview<br> =
This How-To is meant to be a starting point for people to learn use UART for IGEPv2 devices as quickly and easily as possible. In this how-to, we use [http://releases.linaro.org/platform/linaro-m/headless/final/linaro-m-headless-tar-20101108-2.tar.gz Linaro Headless] with [[Linux Kernel 2.6.35.y|Kernel 2.6.35.y]] and [http://downloadslabs.igepisee.esbiz/images/e/labsee/uartUart-test-beta2.tar.bz2 UART test program]
{{Message/Broken Links}}
'''Note''': This program has a debug option using GPIOs to debug via oscilloscope, this option is useful to learnt about the Kernel latencies. Debug has set to "write" and "select" functions.
[[Frequently Asked Questions and Their Answers#How_many_UARTs_are_available.3F|More information]]
= Feedback and Contributing =
= Preparing IGEP =
=== Configure UART1 and UART3 in IGEP with RS232 levels on J960 connector ===
To test UARTs we use UART1 (dev/ttyS0) and UART3 (dev/ttyS2) via J960 connector using RS232 standard.
</pre>
By default, UART3 is used by Kernel serial console, we need to disable it, go to igep.ini file, comment next line: <br>
<pre>console=ttyS2,115200n8</pre> 
=== Check UARTs devices ===
If you don't have setserial installed type:
<pre>apt-get install setserial</pre>
NOTE: Starting from Kernel 2.6.37.y, ttySx are named ttyOx. You need to edit source program. 
=== Connect peripherals ===
(Connect to 3) o---| 9 10 |---x (Not used)
------
</pre> 
=== Send some data ===
Type something in one terminal.
{| cellspacing="1" cellpadding="1" width="200" border="1" align="center" width="200"
|-
| style="text-align: left;" | [[Image:Minicom screenshot.png|640x400px]]
=== Uart Schematic Igep Module ===
{| cellspacing="1" cellpadding="1" width="200" border="1" align="center" width="200"
|-
| [[Image:Uart Schematic Igep Module.png|581x600px]]
= Compile and run program =
Download [http://downloadslabs.igepisee.esbiz/images/e/labsee/uartUart-test-beta2.tar.bz2 program source].
As explained above, the program uses GPIO for debug option via oscilloscope, it is necessary install user-gpio-drv.ko driver inside Linux Kernel, more information [[How to use GPIOs|here]] .
Once you have installed module. Compile program using your Cross Compiler, I used arm-linux-gnueabi-:
<pre>arm-linux-gnueabi-gcc uart-test-beta1.c -o uart-test-beta1 </pre> 
= Testing UART =
Decoded with [http://www.asciitable.com/ ASCII table].
{| cellspacing="1" cellpadding="1" width="200" border="1" align="center" width="200"
|-
| [[Image:Uart decode1withlf.JPG|350x230px]]
Program sends information via UART1 but don't receive response via UART3, because only a process is executed. This problem is repeated every 5 seconds (constant WAIT=5) until other process sends information via UART3 at the same speed. If "select" hasn't been implemented, process would have stayed blocked.<br>
{| cellspacing="1" cellpadding="1" width="200" border="1" align="center" width="200"
|-
| [[Image:Uart select timeout9.JPG|350x230px]]
More information [http://en.wikipedia.org/wiki/RS-232#Standard_details here].
{| cellspacing="1" cellpadding="1" width="200" border="1" align="center" width="200"
|-
| [[Image:Uart voltageparams8.JPG|350x230px]]
Note that wave is degraded when speed is higher
{| cellspacing="1" cellpadding="1" width="200" border="1" align="center" width="200"
|-
| [[Image:Uart 300 o.JPG|260x172px]]
You can see that RS232 have some lag between transmisions. This caused mainly by kernel process management. UART peripheral is controlled by Linux and It isn't a [http://en.wikipedia.org/wiki/Real-time_operating_system real-time operating system].&nbsp;
{| cellspacing="1" cellpadding="1" width="200" border="1" align="center" width="200"
|-
| [[Image:Uart lag left6.JPG|350x230px]]
This program have three I/O functions that connect to UART driver via ioctl: (read(), write() and select()). But select() and write() change process stat to sleep mode until system don't receive or transmit all information via UART. "select" function is used to prevent that read function can be blocked when data aren't available. <br>The next images (program with debug_gpio enabled and 300 bauds speed) show when process is executed or is waiting. Blue=UART1, Violet="write" and Green="select". When GPIO has HIGH value, process is blocked.<br>
{| cellspacing="1" cellpadding="1" width="200" border="1" align="center" width="200"
|-
| [[Image:Uart select5.JPG|260x172px]]
Every full process the number is increased twice. Program checks that this condicion is true, if it isn't accomplished, process will be finish.
{| cellspacing="1" cellpadding="1" width="200" border="1" align="center" width="200"
|-
| [[Image:Uart error test2.png|640x400px]]
4,199
edits