Published on

Published in: Technology
1 Comment
No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide


  1. 1. UART 2010/05/13 by Sean Chen
  2. 2. <ul><li>What’s UART? </li></ul><ul><li>How to use it ? </li></ul><ul><li>UART Protocol </li></ul><ul><li>UART components </li></ul><ul><ul><li>ARM 926-EJS </li></ul></ul><ul><li>Flow Chart </li></ul><ul><ul><li>How to control? </li></ul></ul><ul><ul><li>UART->Initial </li></ul></ul><ul><ul><li>UART->Methods </li></ul></ul><ul><li>How to implement/Debug? </li></ul><ul><ul><li>RS232 </li></ul></ul><ul><ul><li>MAX232 IC </li></ul></ul>
  3. 3. What’s UART? <ul><li>UART </li></ul><ul><ul><li>A universal asynchronous receiver/transmitter is a type of &quot;asynchronous receiver/transmitter&quot;, a piece of computer hardware that translates data between parallel and serial forms. UARTs are commonly used in conjunction with other communication standards such as EIA RS-232 . </li></ul></ul><ul><li>Sample case </li></ul><ul><ul><li>RS232 </li></ul></ul><ul><li>Ref: </li></ul>
  4. 4. How to use it ? <ul><li>How </li></ul><ul><ul><li>With the UART, you can add an LCD, bootloading, bluetooth wireless , make a datalogger , debug code, test sensors , and much more! </li></ul></ul><ul><li>Key words </li></ul><ul><ul><li>Bootloading </li></ul></ul><ul><ul><ul><li>A boot sequence is the initial set of operations that the computer performs when power is switched on. The bootloader typically loads the main operating system for the computer. </li></ul></ul></ul><ul><ul><li>Datalogger </li></ul></ul><ul><ul><ul><li>A data logger (also datalogger or data recorder ) is an electronic device that records data over time or in relation to location either with a built in instrument or sensor or via external instruments and sensors. Increasingly, but not entirely </li></ul></ul></ul><ul><li>Ref : </li></ul>
  5. 5. UART Protocol <ul><li>Signal definition </li></ul><ul><ul><li>TX </li></ul></ul><ul><ul><ul><li>transmitter </li></ul></ul></ul><ul><ul><li>RX </li></ul></ul><ul><ul><ul><li>Receiver </li></ul></ul></ul><ul><ul><li>In asynchronous transmitting, teletype -style UARTs send a &quot;start&quot; bit, five to eight data bits, least-significant-bit first, an optional &quot;parity&quot; bit, and then one, one and a half, or two &quot;stop&quot; bits. The start bit is the opposite polarity of the data-line's idle state. The stop bit is the data-line's idle state, and provides a delay before the next character can start. (This is called asynchronous start-stop transmission). </li></ul></ul>TX RX RX TX M1 M2
  6. 6. UART components <ul><li>A UART usually contains the following components: </li></ul><ul><ul><li>a clock generator, usually a multiple of the bit rate to allow sampling in the middle of a bit period. </li></ul></ul><ul><ul><li>input and output shift registers </li></ul></ul><ul><ul><li>transmit/receive control </li></ul></ul><ul><ul><li>read/write control logic </li></ul></ul><ul><ul><li>transmit/receive buffers (optional) </li></ul></ul><ul><ul><li>parallel data bus buffer (optional) </li></ul></ul><ul><ul><li>First-in, first-out ( FIFO ) buffer memory (optional) </li></ul></ul><ul><li>Ref : </li></ul>
  7. 7. ARM 926-EJS
  8. 8. Flow chart <ul><li>Flow chart </li></ul><ul><ul><li>Boot </li></ul></ul><ul><ul><ul><li>Initial Set the UART </li></ul></ul></ul><ul><ul><ul><ul><li>Check the UART is workable </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Configure setting </li></ul></ul></ul></ul><ul><ul><ul><ul><li>…. </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Initial Done </li></ul></ul></ul></ul><ul><ul><li>Release 2 operator system </li></ul></ul><ul><ul><ul><li>used or unused </li></ul></ul></ul><ul><ul><ul><ul><li>Receive </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Transmit </li></ul></ul></ul></ul>
  9. 9. How to control ? <ul><li>Memory location </li></ul><ul><ul><li>// Devices#define </li></ul></ul><ul><ul><ul><li>UART 0x3CC00000 </li></ul></ul></ul><ul><ul><li>// Registers#define (offset) </li></ul></ul><ul><ul><ul><li>UART0 0x0 </li></ul></ul></ul><ul><li>Register </li></ul><ul><ul><li>#define UART_UTXH 0x20 </li></ul></ul><ul><ul><li>#define UART_URXH 0x24 </li></ul></ul><ul><li>Mode </li></ul><ul><ul><li>#define UART_UCON_RXMODE_SHIFT 0 </li></ul></ul><ul><ul><li>#define UART_UCON_RXMODE_MASK (0x3 << UART_UCON_RXMODE_SHIFT) </li></ul></ul><ul><li>FIFO control </li></ul><ul><ul><li>#define UART_FIFO_RESET_TX 0x4 </li></ul></ul><ul><ul><li>#define UART_FIFO_RESET_RX 0x2 </li></ul></ul><ul><ul><li>#define UART_FIFO_ENABLE 0x1 </li></ul></ul>UART Display 0x00010000 0x00040000 0x000F0000
  10. 10. UART->Initial <ul><li>Initial iboot </li></ul><ul><ul><li>uart_setup(); </li></ul></ul><ul><ul><ul><li>UartHasInit </li></ul></ul></ul><ul><ul><ul><li>clock_gate_switch(UART_CLOCKGATE,ON); </li></ul></ul></ul><ul><ul><ul><ul><li>In boot mode, put the clock on, if done release the memory to operator system </li></ul></ul></ul></ul><ul><ul><ul><li>for(i = 0; i < NUM_UARTS; i++) { … } </li></ul></ul></ul><ul><ul><ul><ul><li>SET_REG(HWUarts[i].ULCON, UART_8BITS); </li></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>Set register data to control each UART set </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><li>uart_set_clk(i, UART_CLOCK_EXT_UCLK0); </li></ul></ul></ul></ul><ul><ul><ul><ul><li>uart_set_sample_rate(i, 16); </li></ul></ul></ul></ul><ul><ul><ul><li>uart_set_flow_control(0, OFF); </li></ul></ul></ul><ul><ul><ul><li>UARTs[i].fifo = ON; </li></ul></ul></ul><ul><ul><ul><li>UartHasInit = TRUE; </li></ul></ul></ul><ul><ul><ul><ul><li>Check UARTinitial is ok or not </li></ul></ul></ul></ul>
  11. 11. UART->Methods <ul><li>Methods </li></ul><ul><ul><li>int uart_write (int ureg, const char *buffer, uint32_t length); </li></ul></ul><ul><ul><li>int uart_read (int ureg, char *buffer, uint32_t length, uint64_t timeout ); </li></ul></ul><ul><ul><ul><li>uint64_t timeout </li></ul></ul></ul><ul><ul><ul><ul><li>Define timeout to retry </li></ul></ul></ul></ul>
  12. 12. MAX232 IC RS232 Test I/O PC host and console mode support
  13. 13. How to implement/Debug? <ul><li>RS232 </li></ul><ul><ul><li>In telecommunications , RS-232 (Recommended Standard 232) is a standard for serial binary single-ended data and control signals connecting between a DTE ( Data Terminal Equipment ) and a DCE ( Data Circuit-terminating Equipment ). It is commonly used in computer serial ports . A similar ITU-T standard is V.24 . </li></ul></ul><ul><li>RS232 pin-map table </li></ul><ul><ul><li> </li></ul></ul><ul><li>MAX232 datasheet </li></ul><ul><ul><li> </li></ul></ul>
  14. 14. <ul><li>RS232 serial cables pin-table </li></ul><ul><ul><li> </li></ul></ul><ul><li>Console mode </li></ul><ul><ul><li>Linux (putty) </li></ul></ul><ul><ul><ul><li> </li></ul></ul></ul><ul><ul><ul><li> </li></ul></ul></ul>