CE-2810 Dr. Mark L. Hornick 1 Using the USART Configuration and Programming.

Slides:



Advertisements
Similar presentations
Serial Interface Dr. Esam Al_Qaralleh CE Department
Advertisements

EUSART Serial Communication.
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.
SCI: Serial Communications Interface Presented by: Sean Kline Chad Smith Jamie Cruce.
Serial I/O - Programmable Communication Interface
Microprocessor based Design for Biomedical Applications MBE 3 – MDBA IV : The ATmega8 Basic Features (3)
COMP3221: Microprocessors and Embedded Systems Lecture 22: Serial Input/Output (II) Lecturer: Hui Wu Session 1, 2005.
Starting with serial Chapter Ten 10.1, 10.2,
Asynchronous Communication Hardware  Data within a DTE is usually stored and moved in a parallel fashion.  Data sent across the channel is generally.
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.
Network and Systems Laboratory nslab.ee.ntu.edu.tw.
Lecture 10 Serial Communication.
The Arduino Platform A “development module”
1 SCI Serial Communication Interface Gerrit Becker James McClearen Charlie Hagadorn October 21, 2004.
Serial Communication Interface (SCI) Kevin Stuart Matt Betts March 27, 2007 ME 6405, Sp 07.
EE138 Serial Communication
Serial Peripheral Interface Module MTT M SERIAL PERIPHERAL INTERFACE (SPI)
Serial Communication ETEC 6416.
S4525A Peripherals & Enhanced FLASH 1 © 1999 Microchip Technology Incorporated. All Rights Reserved. S4525A Peripherals & Enhanced FLASH 1 Peripherals.
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)
Serial Communications
Scott Baker Will Cross Belinda Frieri March 9 th, 2005 Serial Communication Overview ME4447/6405.
Advanced Microprocessor1 I/O Interface Programmable Interval Timer: 8254 Three independent 16-bit programmable counters (timers). Each capable in counting.
Example. SBUF Register SCON Register(1) SCON Register(2)
 8251A is a USART (Universal Synchronous Asynchronous Receiver Transmitter) for serial data communication.  Programmable peripheral designed for synchronous.
NS Training Hardware. Serial Controller - UART.
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
ATtiny23131 A SEMINAR ON AVR MICROCONTROLLER ATtiny2313.
1 October 26, 2006ME 6405 MechatronicsSerial Communication Interface Brian Guerriero Jon Rogers Robert Thiets.
Serial Communications Interface Module Slide #1 of 19 MC68HC908GP20 Training PURPOSE -To explain how to configure and use the Serial Communications Interface.
© 2009, Renesas Technology America, Inc., All Rights Reserved 1 Course Introduction  Purpose:  This course provides an overview of the serial communication.
ELE22MIC Lecture 9-12 Serial Communications AVR USART –Universal Synchronous Asynchronous Receiver Transmitter (ACIA: Asynchronous Communications Interface.
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.
Tiva C TM4C123GH6PM UART Embedded Systems ECE 4437 Fall 2015 Team 2:
SCI Communication Proudly Presented By: Adam Cardi & Aaron Enes.
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
CS-401 Computer Architecture & Assembly Language Programming
Source: Serial Port Source:
SERIAL PORT PROGRAMMING
ATMEGA 32 CONNECTIONS TO RS232; UDR AND UCSR REGISTERS
COMP2121: Microprocessors and Interfacing
Computer Organization and Design
Source: Serial Port Source:
USART Universal Synchronous Asynchronous Receiver Transmitter
UART Serial Port Programming
Asynchronous Serial Communications
Serial Communication Interface: Using 8251
UART Protocol Chapter 11 Sepehr Naimi
COMP3221: Microprocessors and Embedded Systems
Lecturer: Reza Arjmandi Autumn 2015
Chapter 13 DMA Programming.
Configuration and Programming
NS Training Hardware.
Source: Serial Port Source:
EUSART Serial Communication.
Serial Communication 19th Han Seung Uk.
Source: Serial Port Source:
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:

CE-2810 Dr. Mark L. Hornick 1 Using the USART Configuration and Programming

Configuring the USART Several I/O registers are used to: 1. Control the configuration of the USART Baud rate (bits/s) Parity (even/odd/none) Number of data bits (4-9) Framing ( 1 or 2 stop bits) 2. Represent the status of a recent transmission or reception Frame errors Data overrun errors Tx complete Rx complete CS-280 Dr. Mark L. Hornick 2

Lots of I/O registers make configuring the USART a bit complicated: UCSRA – USART Control/Status Register A Mainly status flags UCSRB – USART Control/Status Register B Flags for enabling transmitting, receiving, interrupts UCSRC – USART Control/Status Register C Mode selection UBRRH, UBRRL– USART Baud Rate Registers (16 bit combined) Baud rate selection UDR– USART Data Register Does two things at once: Contains data to be transmitted, or Data that is received CE-2810 Dr. Mark L. Hornick 3 Full documentation on the USART can be found (around p 146) of the Atmega32.pdf reference manual

UBRRL/UBRRH are used to set transmit and receive speed URSEL – Register select UCSRC I/O address overlaps with address of UBRRH. Set to 0 if writing this Register as UBRRH; otherwise UCSRC UBRR11:0 – Baud Rate select 12-bit register specifying the USART transmit/receive baud rate. Use the following table for calculating the value to place in these bits. BAUD is in bits/sec, f osc is the Atmega32 clock frequency. CE-2810 Dr. Mark L. Hornick 4

UCSRB/C serve multiple purposes UCSZ2, UCSZ1, UCSZ0 – Character size select Together, these set the number of data bits being transmitted or received Set these to (0:1:1) for 8 data bits; see reference manual for other settings URSEL – Register select UCSRC I/O address overlaps with address of UBRRH. Set to 1 when using this Register as UCSRC; otherwise UBRRH UMSEL – Mode select Set to 0 for Asynchronous mode UPM1, UPM0 – Parity mode select Parity disabled (0:0), Even (1:0), Odd (1:1), Reserved (0:1) USBS– Stop bit select Set to 0 for framing using a single Stop Bit UCPOL – Clock polarity (do not use) CE-2810 Dr. Mark L. Hornick 5

UCSRB/C continued CE-2810 Dr. Mark L. Hornick 6 RXCIE – Receive complete interrupt enable Set to enable Receive Complete Interrupt. TXCIE – Transmit complete interrupt enable Set to enable Transmit Complete Interrupt. UDRIE – Data Register Empty interrupt enable Set to enable UDRE Interrupt. RXEN – Receiver Enable Set to enable the USART Receiver TXEN – Transmitter Enable Set to enable the USART Transmitter UCSZ2 – see previous slide explaining UCSRC bits RXB8 – contains the 9 th data bit when receiving 9-bit data TXB8 – contains the 9 th data bit when transmitting 9-bit data

UCSRA contains status bits you read RXC – Receive complete Set when data is received in the Receive Buffer (RXB) TXC – Transmit complete Set when data in the Transmit Buffer has been completely transmitted and no new data in UDR; manually cleared by writing a 1 to this bit UDRE – Data Register Empty Set when Transmit Buffer is ready to accept new data to be transmitted FE – Frame Error Set when Data in Receive Buffer had a frame error detected DOR – Data Overrun Set when Receive Buffer is full (but unread), and new data is coming in PE – Parity Error Set when Data in Receive Buffer had a parity error detected (if parity checking was enabled) U2X – Transmission speed doubler Leave at 0 (default). When explicitly set to 1, doubles the transmission speed of the USART MPCM– Multiprocessor Comm mode Leave at 0 (default) for normal communication CE-2810 Dr. Mark L. Hornick 7

The UDR register contains the value the USART transmits or receives UDR– USART Data Register TXB and RXB I/O addresses overlap When UDR is written, the contents are shifted to the Transmit Buffer (TXB). This takes a short period of time When UDR is read, the contents of the Receive Buffer (RXB) are first shifted into UDR, so that UDR contains the contents of RXB CE-2810 Dr. Mark L. Hornick 8

How to use the USART 1. Set baud rate via UBRRH and UBRRL 2. Enable Transmit and Receive via UCSRB 3. Disable all USART interrupts via UCSRB 4. Set Parity, #Data bits, #Stop bits, Async via UCSRC 5. To Transmit: Poll UDRE bit (bit 5) in USCRA until set (ready to transmit) Once set, place character to be written in UDR register, which causes the USART hardware to transmit that character 6. To Receive: Poll RXC bit in UCSRA until set (character was received) Once set, received char will be in UDR register, and the UDR register will be able to be read. CS-280 Dr. Mark L. Hornick 9

The USART can receive while it is transmitting But the TXB and RXB buffers can each hold only one character So you must keep polling RXC to avoid dropping received characters And you must poll UDRE before sending another character to ensure that TXC has been emptied CS-280 Dr. Mark L. Hornick 10