UART Protocol Chapter 11 Sepehr Naimi www.NicerLand.com.

Slides:



Advertisements
Similar presentations
EUSART Serial Communication.
Advertisements

Serial Communications Interface (SCI) Michael LennardZachary PetersBao Nguyen.
11-1 ECE 424 Design of Microprocessor-Based Systems Haibo Wang ECE Department Southern Illinois University Carbondale, IL I/O System Design.
ECT 357 Ch 18 UART. Today’s Quote: Be careful that your marriage doesn’t become a duel instead of a duet. Be careful that your marriage doesn’t become.
The 8051 Microcontroller Chapter 5 SERIAL PORT OPERATION.
Serial I/O - Programmable Communication Interface
Hierarchy of I/O Control Devices
COMP3221: Microprocessors and Embedded Systems Lecture 22: Serial Input/Output (II) Lecturer: Hui Wu Session 1, 2005.
USARTS CS423 Dick Steflik. USART ● Universal Synchronous Asynchronous Receiver Transmitter ● used to send and receive small packets over a serial line.
USART and Asynchrono us Communica tion The USART is used for synchronous and asynchronous serial communication. USART = Universal Synchronous/Asynchronous.
7-1 Digital Serial Input/Output Two basic approaches  Synchronous shared common clock signal all devices synchronised with the shared clock signal data.
ECE 353 Introduction to Microprocessor Systems Michael G. Morrow, P.E. Week 13.
The Arduino Platform A “development module”
EE138 Serial Communication
Serial Communication ETEC 6416.
The 8051 Microcontroller and Embedded Systems
Lecture Set 9 MCS-51 Serial Port.
Universal Synchronous/Asynchronous Receiver/Transmitter (USART)
Microprocessor based Design for Biomedical Applications MBE 3 – MDBA III : The ATmega8 Basic Features (2)
Universal Asynchronous Receiver/Transmitter (UART)
ECE 353 Introduction to Microprocessor Systems Michael Schulte Week 13.
Embedded System Design Laboratory October 4, 2002Stanford University - EE281 Lecture #3#1 Lecture #3 Outline Announcements AVR Processor Resources –UART.
Scott Baker Will Cross Belinda Frieri March 9 th, 2005 Serial Communication Overview ME4447/6405.
 8251A is a USART (Universal Synchronous Asynchronous Receiver Transmitter) for serial data communication.  Programmable peripheral designed for synchronous.
Serial Communication Interface Ta Kim Nicholas Earnhart Razid Ahmad ME 6405 – Fall 2008 November 6, 2008.
CE-2810 Dr. Mark L. Hornick 1 Using the USART Configuration and Programming.
ATtiny23131 A SEMINAR ON AVR MICROCONTROLLER ATtiny2313.
Communicating. The ATmega16 communicates through one of the following ways: Serial Peripheral Interface (SPI) Universal Synchronous and Asynchronous serial.
CE-2810 Dr. Mark L. Hornick 1 Serial Communications Sending and receiving data between devices.
Chap.6.3 UART.
8251 USART.
Lecture 15. Modem Controller Register 4310 DTR 0 = Polling Operator 1 = Interrupts Enabled RTS 1 =Self Test 0 =Normal.
Digital Logic Design Alex Bronstein
The HCS12 SCI Subsystem A HCS12 device may have one or two serial communication interface. These two SCI interfaces are referred to as SCI0 and SCI1. The.
Serial mode of data transfer
EE 107 Fall 2017 Lecture 5 Serial Buses – UART & SPI
Source: Serial Port Source:
Serial I/O and Data Communication.
SERIAL PORT PROGRAMMING
ATMEGA 32 CONNECTIONS TO RS232; UDR AND UCSR REGISTERS
1 Input-Output Organization Computer Organization Computer Architectures Lab Peripheral Devices Input-Output Interface Asynchronous Data Transfer Modes.
COMP2121: Microprocessors and Interfacing
E3165 DIGITAL ELECTRONIC SYSTEM
Atmega32 Serial Programming Basics
DIGITAL DATA COMMUNICATION TECHNIQUES
Computer Organization and Design
Source: Serial Port Source:
UART Serial Port Programming
DIGITAL DATA COMMUNICATION TECHNIQUES
Asynchronous Serial Communications
Serial Communication Interface: Using 8251
Serial Communication Interface
Communications channels تقديم المهندس سنان محمد حسن
COMP3221: Microprocessors and Embedded Systems
Lecturer: Reza Arjmandi Autumn 2015
Преглед Начин функционисања Имплементације
DIGITAL DATA COMMUNICATION TECHNIQUES
Configuration and Programming
SPI Protocol Sepehr Naimi
Programmable Data Communication Blocks
Source: Serial Port Source:
CHAPTER SERIAL PORT PROGRAMMING. Basics of Serial Communication Computers transfer data in two ways: ◦ Parallel  Often 8 or more lines (wire.
EUSART Serial Communication.
Serial Communication 19th Han Seung Uk.
Source: Serial Port Source:
PIC Serial Port Interfacing
8051SERIAL PORT PROGRAMMING
PIC Serial Port Interfacing
Introduction Communication Modes Transmission Modes
AVR UART The UART, or Universal Asynchronous Receiver Transmitter, provides hardware support for a serial port on AVR processors Signaling is compatible.
Presentation transcript:

UART Protocol Chapter 11 Sepehr Naimi www.NicerLand.com

Topics Communication theory UART protocol UART in AVR Parallel vs. Serial Direction: Simplex, Half duplex, Full duplex Synchronization: Synchronous vs. Asynchronous Line coding UART protocol UART in AVR UART Registers Some programs

Parallel vs. Serial Parallel For short distances Not applicable for long distances More expensive Cross-talk problem

Direction Simplex Half Duplex Full Duplex

Synchronization Synchronous Asynchronous

Line coding Line coding: presenting data using signals Digital NRZ-L: Coding using level of voltage TTL RS232 NRZ-I: Inverting or not inverting Analog: using sine waves ASK FSK PSK RS232 NRZ-I TTL

UART Protocol Serial Asynchronous Full duplex

USART (Universal Synchronous Asynchronous Receive Transmit) USART devices can be used to communicate asynchronously (UART) and synchronously. Since the synchronous capability of USART is not used nowadays, we concentrate on UART.

UART in AVR Control registers: (initialize speed, data size, parity, etc) UBRR, UCSRA, UCSRB, and UCSRC Send/receive register UDR Status register UCSRA

Baud rate System clock UART baud rate

Example: Find the UBRR value for 9600bps. Solution:

Some Standard Baud rates 1200 2400 4800 9600 19,200 38,400 57,600 115,200

UCSRB RXCIE0 (Bit 7): Receive Complete Interrupt Enable To enable the interrupt on the RXC0 flag in UCSR0A you should set this bit to one. TXCIE0 (Bit 6): Transmit Complete Interrupt Enable To enable the interrupt on the TXC0 flag in UCSR0A you should set this bit to one. UDRIE0 (Bit 5): USART Data Register Empty Interrupt Enable To enable the interrupt on the UDRE0 flag in UCSR0A you should set this bit to one. RXEN0 (Bit 4): Receive Enable To enable the USART receiver you should set this bit to one. TXEN0 (Bit 3): Transmit Enable To enable the USART transmitter you should set this bit to one. UCSZ02 (Bit 2): Character Size This bit combined with the UCSZ1:0 bits in UCSRC sets the number of data bits (character size) in a frame. RXB80 (Bit 1): Receive data bit 8 This is the ninth data bit of the received character when using serial frames with nine data bits. TXB80 (Bit 0): Transmit data bit 8 This is the ninth data bit of the transmitted character when using serial frames with nine data bits.

UCSRC UMSEL01:00 (Bits 7:6): USART Mode Select These bits select the operation mode of the USART: 00 = Asynchronous USART operation 01 = Synchronous USART operation 10 = Reserved 11 = Master SPI (MSPIM) UPM01:00 (Bit 5:4): Parity Mode These bits disable or enable and set the type of parity generation and check. 00 = Disabled 01 = Reserved 10 = Even Parity 11 = Odd Parity USBS0 (Bit 3): Stop Bit Select This bit selects the number of stop bits to be transmitted. 0 = 1 bit 1 = 2 bits UCSZ01:00 (Bit 2:1): Character Size These bits combined with the UCSZ02 bit in UCSR0B set the character size in a frame. UCPOL0 (Bit 0): Clock Polarity This bit is used for synchronous mode. UCSZ02 UCSZ01 UCSZ00 Char. size 5-bit 1 6-bit 7-bit 8-bit 9-bit

UDR

UCSRA RXC0 (Bit 7): USART Receive Complete 0 This flag bit is set when there are new data in the receive buffer that are not read yet. It is cleared when the receive buffer is empty. It also can be used to generate a receive complete interrupt. TXC0 (Bit 6): USART Transmit Complete 0 This flag bit is set when the entire frame in the transmit shift register has been transmitted and there are no new data available in the transmit data buffer register (TXB). It can be cleared by writing a one to its bit location. Also it is automatically cleared when a transmit complete interrupt is executed. It can be used to generate a transmit complete interrupt. UDRE0 (Bit 5): USART Data Register Empty 0 This flag is set when the transmit data buffer is empty and it is ready to receive new data. If this bit is cleared you should not write to UDR0 because it overrides your last data. The UDRE0 flag can generate a data register empty interrupt. FE0 (Bit 4): Frame Error 0 This bit is set if a frame error has occurred in receiving the next character in the receive buffer. A frame error is detected when the first stop bit of the next character in the receive buffer is zero. DOR0 (Bit 3): Data OverRun 0 This bit is set if a data overrun is detected. A data overrun occurs when the receive data buffer and receive shift register are full, and a new start bit is detected. PE0 (Bit 2): Parity Error 0 This bit is set if parity checking was enabled (UPM1 = 1) and the next character in the receive buffer had a parity error when received. U2X0 (Bit 1): Double the USART Transmission Speed 0 MPCM0 (Bit 0): Multi-processor Communication Mode 0

Program: sending character ‘G’ continuously #include <avr/io.h> void usart_init (void) { UCSR0B = (1<<TXEN0); UCSR0C = (1<<UCSZ01)|(1<<UCSZ00); UBRR0L = 103; //baud rate = 9600bps } void usart_send (unsigned char ch) while (! (UCSR0A & (1<<UDRE0))); //wait until UDR0 is empty UDR0 = ch; //transmit ch int main (void) usart_init(); //initialize the USART while(1) //do forever usart_send ('G'); //transmit ‘G’ letter return 0;

Program 2: It receives bytes of data serially and puts them on Port B. #include <avr/io.h> int main (void) { DDRB = 0xFF; //Port B is output UCSR0B = (1<<RXEN0); //initialize USART0 UCSR0C = (1<<UCSZ01)|(1<<UCSZ00); UBRR0L = 103; while(1) while (! (UCSR0A & (1<<RXC0))); //wait until new data PORTB = UDR0; } return 0;

USB to serial converter in Arduino

MAX232