Uart

14

Click here to load reader

Transcript of Uart

Page 1: Uart

UART

2010/05/13 by Sean Chen

Page 2: Uart

• What’s UART?• How to use it ?• UART Protocol• UART components

– ARM 926-EJS

• Flow Chart– How to control?– UART->Initial– UART->Methods

• How to implement/Debug?– RS232– MAX232 IC

Page 3: Uart

What’s UART?

• UART– A universal asynchronous receiver/transmitter is a type of "a

synchronous receiver/transmitter", 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.

• Sample case– RS232

• Ref: http://en.wikipedia.org/wiki/Universal_asynchronous_receiver/transmitter

Page 4: Uart

How to use it ?• How

– With the UART, you can add an LCD, bootloading, bluetooth wireless, make a datalogger, debug code, test sensors, and much more!

• Key words– Bootloading

• 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.

– Datalogger• A data logger (also datalogger or data recorder) is an electronic devi

ce 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

• Ref :http://www.societyofrobots.com/microcontroller_uart.shtml

Page 5: Uart

UART Protocol

• Signal definition– TX

• transmitter

– RX • Receiver

– In asynchronous transmitting, teletype-style UARTs send a "start" bit, five to eight data bits, least-significant-bit first, an optional "parity" bit, and then one, one and a half, or two "stop" 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).

TX

RX

RX

TXM1 M2

Page 6: Uart

UART components

• A UART usually contains the following components:– a clock generator, usually a multiple of the bit rate to allow sampl

ing in the middle of a bit period. – input and output shift registers – transmit/receive control – read/write control logic – transmit/receive buffers (optional) – parallel data bus buffer (optional) – First-in, first-out (FIFO) buffer memory (optional)–

• Ref :http://en.wikipedia.org/wiki/Universal_asynchronous_receiver/transmitter

Page 7: Uart

ARM 926-EJS

Page 8: Uart

Flow chart

• Flow chart– Boot

• Initial Set the UART– Check the UART is workable– Configure setting– ….– Initial Done

– Release 2 operator system• used or unused

– Receive– Transmit

Page 9: Uart

How to control ?• Memory location

– // Devices#define • UART 0x3CC00000

– // Registers#define (offset)• UART0 0x0

• Register– #define UART_UTXH 0x20– #define UART_URXH 0x24

• Mode– #define UART_UCON_RXMODE_SHIFT 0– #define UART_UCON_RXMODE_MASK (0x3 << UART_UCON_RXMO

DE_SHIFT)• FIFO control

– #define UART_FIFO_RESET_TX 0x4– #define UART_FIFO_RESET_RX 0x2– #define UART_FIFO_ENABLE 0x1

UART

Display0x00010000

0x00040000

0x000F0000

Page 10: Uart

UART->Initial

• Initial iboot– uart_setup();

• UartHasInit• clock_gate_switch(UART_CLOCKGATE,ON);

– In boot mode, put the clock on, if done release the memory to operator system

• for(i = 0; i < NUM_UARTS; i++) { … }– SET_REG(HWUarts[i].ULCON, UART_8BITS);

» Set register data to control each UART set– uart_set_clk(i, UART_CLOCK_EXT_UCLK0);– uart_set_sample_rate(i, 16);

• uart_set_flow_control(0, OFF);• UARTs[i].fifo = ON;• UartHasInit = TRUE;

– Check UARTinitial is ok or not

Page 11: Uart

UART->Methods

• Methods– int

uart_write(int ureg, const char *buffer, uint32_t length);

– int uart_read(int ureg, char *buffer, uint32_t length, uint64_t timeout);

• uint64_t timeout– Define timeout to retry

Page 12: Uart

MAX232 IC

RS232

Test I/O

PC host and console mode support

Page 13: Uart

How to implement/Debug?

• RS232– 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.

• RS232 pin-map table– http://en.wikipedia.org/wiki/RS-232

• MAX232 datasheet– http://www.datasheetcatalog.com/datasheets_pdf/M/A/X/2/

MAX232.shtml

Page 14: Uart

• RS232 serial cables pin-table – http://www.lammertbies.nl/comm/cable/RS-23

2.html

• Console mode– Linux (putty)

• http://www.vanemery.com/Linux/Serial/serial-console.html

• http://ed32.blogspot.com/2010/01/ubuntuputty.html