330 likes | 973 Views
UART. By: Jonathan Levesque. Table of contents. System view Applications Hardware vs. firmware spec: Atmel AVR, protocol, programming options C functions. What is UART. Computer hardware Transfers data Can also communicate synchronously. Features of UART.
E N D
UART By: Jonathan Levesque
Table of contents • System view • Applications • Hardware vs. firmware • spec: Atmel AVR, protocol, programming options • C functions
What is UART • Computer hardware • Transfers data • Can also communicate synchronously
Features of UART • There is no clock for UARTs • Data (D) is transmitted one bit at a time
Why use UART? • Cheap • Good when high speed isn’t required • PC devices such as mice and modems used to often be asynchronous serial devices
Uses • Communication between computers • Internet access • Mainframe access
Pros/Cons Pros: Cons: • Low cost • Simple hardware • Low maintenance • Slow • Unreliable • Becoming less comon
Timing and Baud Rate • Crystal or External Clock • Standard Clock Frequencies 1.8432MHz, 3.6864MHz, 7.3728MHz 14.7456MHz, 18.432MHz, 22.1114MHz • 16X timing for internal operation • Standard Data rates: 110 to 921.6Kbps • Baud Rate Calculation: Baud Rate = (Clock Frequency / 16 ) / (Divisor)
Hardware Transmitter Receiver
Transmitter • Parallel-to-serial conversion • Parity generation • 16X timing for bit shifting • Character Framing
Receiver • Serial-to-Parallel Conversion • 16X timing clock for mid bit sampling and verification • Parity sampling & verification • Stop bit sampling & verification • Data-bit sampling
Software • Transmit (TBIT = 1 bit period) - Send 0, wait TBIT -Send D0, wait TBIT -Send D1, wait TBIT -. . . -Send D7 or parity, wait TBIT -Send 1, wait TBIT
Software • Receive (TBIT = 1 bit period) - Wait for 0 -Wait 1/2 TBIT, If 0 continue else restart -Wait TBIT, get D0 -Wait TBIT, get D1 -. . . -Wait TBIT, get D7 or parity -Wait TBIT, If 1 okay else frame error.
Communication standards/protocols • USB • Bluetooth • HTTP • FTP • RS232 • CAN • LIN • RS485 • SPI • TTL Serial (our UART) • Parallel Ports • TCP/IP • I2C • Zigbee • SimplicTI • WiFi • 802.15.4 • RF
C function • #include "reg_c51.h" • char uart_data; • /** • * FUNCTION_PURPOSE: This file set up uart in mode 1 (8 bits uart) with • * timer 1 in mode 2 (8 bits auto reload timer). • * FUNCTION_INPUTS: void • * FUNCTION_OUTPUTS: void • */ • void main (void) • { • SCON = 0x50; /* uart in mode 1 (8 bit), REN=1 */ • TMOD = TMOD | 0x20 ; /* Timer 1 in mode 2 */ • TH1 = 0xFD; /* 9600 Bds at 11.059MHz */ • TL1 = 0xFD; /* 9600 Bds at 11.059MHz */ • ES = 1; /* Enable serial interrupt*/ • EA = 1; /* Enable global interrupt */ • TR1 = 1; /* Timer 1 run */ • while(1); /* endless */ • } • /** • * FUNCTION_PURPOSE: serial interrupt, echo received data. • * FUNCTION_INPUTS: P3.0(RXD) serial input • * FUNCTION_OUTPUTS: P3.1(TXD) serial output • */ • void serial_IT(void) interrupt 4 • { • if (RI == 1) • { /* if reception occur */ • RI = 0; /* clear reception flag for next reception */ • uart_data = SBUF; /* Read receive data */ • SBUF = uart_data; /* Send back same data on uart*/ • } • else TI = 0; /* if emission occur */ • } /* clear emission flag for next emission*/
Manufacturers • Intersil • Maxim • Micrel semiconductor • National semiconductor • NXP • Texas Instruments