Chap.6.3 UART.

Slides:



Advertisements
Similar presentations
Serial Communications Interface (SCI) Michael LennardZachary PetersBao Nguyen.
Advertisements

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
1 Serial Communications Lecture In these notes... General Communications Serial Communications –RS232 standard –UART operation –Polled Code –Interrupt.
Hierarchy of I/O Control Devices
COMP3221: Microprocessors and Embedded Systems Lecture 22: Serial Input/Output (II) Lecturer: Hui Wu Session 1, 2005.
Better Debugging of Embedded via a Debug Port ECE152.
Serial I/O Communication
Using the AVR UART Demo. Overview  How do I know what to do?  What do I do?  Setup the Wunderboard  Setup the Host computer  Setup the #define statements.
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.
Better Debugging of Embedded via a Debug Port ECE152.
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.
ECE 353 Introduction to Microprocessor Systems Michael G. Morrow, P.E. Week 13.
1 מעבדה במבוא לתקשורת בהתאם לאמונה שלי שתלמיד שאינו שולט באנגלית לא יכול להתהדר בתואר אקדמי במדעי המחשב, אזי : זה השקף האחרון בעברית שתראו בקורס.
The Arduino Platform A “development module”
1 SCI Serial Communication Interface Gerrit Becker James McClearen Charlie Hagadorn October 21, 2004.
INPUT-OUTPUT ORGANIZATION
Serial Communication Interface (SCI) Kevin Stuart Matt Betts March 27, 2007 ME 6405, Sp 07.
EE138 Serial Communication
Serial Communication ETEC 6416.
Serial Port I/O Serial port sends and receives data one bit at a time. Serial communication devices are divided into: Data Communications Equipment (DCE),
Digilent System Board Capabilities Serial Port (RS-232) Parallel Port 1 Pushbutton Hint: Good for a reset button Connected to a clock input. See Digilent.
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.
Microprocessors 2 lesson Subjects lesson 7 Planning Interrupts Serial communication /USART Questions.
Embedded System Design Laboratory October 4, 2002Stanford University - EE281 Lecture #3#1 Lecture #3 Outline Announcements AVR Processor Resources –UART.
5. Serial Communication 충북인력개발원 전자과 공학박사 강원찬.
Scott Baker Will Cross Belinda Frieri March 9 th, 2005 Serial Communication Overview ME4447/6405.
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.
Serial Communications
Universal Asynchronous Receiver/Transmitter (UART)
CE-2810 Dr. Mark L. Hornick 1 Using the USART Configuration and Programming.
Asynchronous Serial I/O Unit 12 - Part 1. SCI Registers – Channel 0 SCI0BDH – SCI Baud Rate Register High Byte SCI0BDL – SCI Baud Rate Register Low.
ATtiny23131 A SEMINAR ON AVR MICROCONTROLLER ATtiny2313.
1 October 26, 2006ME 6405 MechatronicsSerial Communication Interface Brian Guerriero Jon Rogers Robert Thiets.
Interrupt. incoming Lab. Interrupt an asynchronous signal indicating the need for attention hardware interrupt/software interrupt call “interrupt service.
Serial Communications Interface Module Slide #1 of 19 MC68HC908GP20 Training PURPOSE -To explain how to configure and use the Serial Communications Interface.
Extended Uart The High Speed Digital Systems Laboratory, Electrical Engineering Faculty, Technion By: Marganit Fina Supervisor: Rivkin Ina Winter 2007/8.
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.
8251 USART.
Tiva C TM4C123GH6PM UART Embedded Systems ECE 4437 Fall 2015 Team 2:
SCI Communication Proudly Presented By: Adam Cardi & Aaron Enes.
Lecture 15. Modem Controller Register 4310 DTR 0 = Polling Operator 1 = Interrupts Enabled RTS 1 =Self Test 0 =Normal.
Serial mode of data transfer
CS-401 Computer Architecture & Assembly Language Programming
EE 107 Fall 2017 Lecture 5 Serial Buses – UART & SPI
UQC113S2 – Embedded Systems
SERIAL PORT PROGRAMMING
ATMEGA 32 CONNECTIONS TO RS232; UDR AND UCSR REGISTERS
COMP2121: Microprocessors and Interfacing
Atmega32 Serial Programming Basics
Computer Organization and Design
UART Protocol Chapter 11 Sepehr Naimi
COMP3221: Microprocessors and Embedded Systems
Lecturer: Reza Arjmandi Autumn 2015
Configuration and Programming
Serial Communication 19th Han Seung Uk.
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:

Chap.6.3 UART

UART Universal Asynchronous Receiver/Transmitter USART a piece of computer hardware that translates data between parallel and serial forms parallel : inside computer serial : serial communication USART universal synchronous/asynchronous receiver/transmitter RS-232C protocol Baud Rate or bps : bits per second stop bit : 1, 1.5, 2 bit parity : error detecting code data length : number of data bits in a frame

USART in ATmega128 – Block Diagram : Register : Pin-Out

USART in ATmega128 Frame Formats : 1 start bit 5,6,7,8 or 9 data bits no, even or odd parity bit 1 or 2 stop bits

USART in ATmega128 Dual USART USART0 USART1

USART Register 1 data register, 3 control registers, 2 baud rate registers UDRn - USARTn I/O Data Register (n=0 or 1) C programming (if USART0 is used) when transmit, UDR0 = data; when received, data = UDR0;

UCSRnA :USART Control and Status Register A RXCn : USART Receive Complete set (=‘1’) when there are unread data in the receive buffer TXCn: USART Transmit Complete UDREn: USART Data Register Empty set (=‘1’) when the buffer is empty and therefore ready to be written FEn: Frame Error DORn: Data OverRun UPEn: Parity Error U2Xn: Double the USART Transmission Speed MPCMn: Multi-Processor Communication Mode

UCSRnB :USARTn Control and Status Register B RXCIEn: RX Complete Interrupt Enable TXCIEn: TX Complete Interrupt Enable UDRIEn: USART Data Register Empty Interrupt Enable RXENn: Receiver Enable set(=‘1’) then receiver is enabled TXENn: Transmitter Enable set(=‘1’) then transmitter is enabled UCSZn2: Character Size sets the number of data bits combined with UCSZn1:0 bit in UCSRnC RXB8n: Receive Data Bit 8 TXB8n: Transmit Data Bit 8

UCSRnC :USARTn Control and Status Register C UMSELn: USART Mode Select asynchronous (=‘0’), synchronous (=‘1’) UPMn1:0: Parity Mode USBSn: Stop Bit Select 1 stop bit (=‘0’), 2 stop bits (=‘1’) UCPOLn: Clock Polarity

UCSRnC :USARTn Control and Status Register C UCSZn1:0: Character Size UCSZn2: Character Size (in UCSRnB )

UBRRnL /UBRRnH - USART Baud Rate Registers UBRRn[11:0]: USARTn Baud Rate Register % fosc = system clock freq.

Register Addresses and Pin-Out for USART Address/Pin-Out USART1 UDR0 UDR1 UCSR0A UCSR1A UCSR0B UCSR1B UCSR0C UCSR1C UBRR0L UBRR1L UBRR0H UBRR1H RXD0 RXD1 TXD0 TXD1 XCK0 XCK1

USART Demo Program USART 통신 하이퍼 터미널 Demo program Key Board

USART 초기화 Port 설정 USART1 사용 DDRD의 3 bit 는 출력/2 bit 는 입력) Baud Rate = 115200 (fosc = 7.3728 MHz) No parity UPM1[1:0 ]= 0 0 1 Stop bit USBS1 = 0 8 data bits UCSZ1[2:0] = 0 1 1

USART 초기화 - Register Setting bit 7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 DDRD UCSR1A UCSR1B UCSR1C UBRR1H UBRR1L

USART 초기화 program DDRD &= 0xFB; DDRD |= 0x08; UCSR1A = 0x00; UCSR1B = 0x18; UCSR1C = 0x06; UBRR1H = 0x00; UBRR1L = 0x03;

Transmit / Receive function void txd_char(unsigned char data){ while( (UCSR1A & 0x20) == 0 ); UDR1 = data; } unsigned char rxd_char(){ unsigned char data; while( (UCSR1A & 0x80) == 0 ); data = UDR1; return data;

USART demo program #include <avr/io.h> /* txd_char(), rxd_char()의 선언 및 정의 */ int main() { unsigned char text[]=“\r\n Micro-computer USART 1 Demo \r\n”; unsigned char echo[]=“ECHO>>”; unsigned char i=0; /* 초기화 code */ while(text[i] != ‘\0’) txd_char(text[i++]); i = 0; while(echo[i] != ‘\0’) txd_char(echo[i++]); while(1) txd_char(rxd_char()); return 0; }

USART demo program 실행 방법 프로그램 컴파일 & 다운로드 ISP Program 창 닫기 AVR-ISP 스위치를 UART로 변경 하이퍼터미널 실행 및 설정 시작 -> 프로그램 -> 보조프로그램 -> 통신 -> 하이퍼터미널

실습 과제 #1. USART0를 이용하여 demo program을 작성하시오. #2. #include <avr/io.h>를 제거하시오. #3. 다음의 기능을 수행하는 program을 작성하시오. ‘r’ key : LED off; ‘i’ key : LED 증가 /* 00 -> 01 -> 10 -> 11 -> 00 … */ ‘d’ key : LED 감소 /* 00 -> 11 -> 10 -> 01 -> 00 -> 11 … */ ‘s’ key : LED on;

Reference Code /* Register 정의 */ /* txd_char(), rxd_char()의 선언 및 정의 */ int main() { /* 변수 선언 */ /* 초기화 code */ while(1) { cmd = rxd_char(); switch (cmd){ /* key 입력에 따른 작업 수행 */ } return 0;