USART and Asynchronous Communication



Similar documents
Serial Communications

Objectives. Basics of Serial Communication. Simplex vs Duplex. CMPE328 Microprocessors (Spring ) Serial Interfacing. By Dr.

8051 Serial Port. Crystal TXD. I/O Device RXD. Embedded Systems Peripherals

Using Xbee in Serial Communication

RS-422/485 Multiport Serial PCI Card. RS-422/485 Multiport Serial PCI Card Installation Guide

Serial Communications

USB TO SERIAL ADAPTER

Parallel IO. Serial IO. Parallel vs. Serial IO. simplex vs half-duplex vs full-duplex. Wires: Full Duplex. Wires: Simplex, Half-duplex.

Elettronica dei Sistemi Digitali Costantino Giaconia SERIAL I/O COMMON PROTOCOLS

1-Port R422/485 Serial PCIe Card

Microcomputer Protocol Implementation at Local Interconnect Network Georgi Krastev

AVR305: Half Duplex Compact Software UART. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

VMR6512 Hi-Fi Audio FM Transmitter Module

RS-232 Communications Using BobCAD-CAM. RS-232 Introduction

INFORMATICA INDUSTRIALE

Software User Guide UG-461

INFORMATICA INDUSTRIALE

AVR317: Using the Master SPI Mode of the USART module. 8-bit Microcontrollers. Application Note. Features. Introduction

Design and Implementation of Home Monitoring System Using RF Technology

RS-485 Protocol Manual

a8251 Features General Description Programmable Communications Interface

LINDY ELECTRONICS LIMITED & LINDY-ELEKTRONIK GMBH - SECOND EDITION

2-Port RS232/422/485 Combo Serial PCI Card

CENTRONICS interface and Parallel Printer Port LPT

Instant Theft Alert and Tracking System in Car

APPLICATION NOTE. Atmel AT02607: Wireless Product Development Using Atmel Studio and ASF. Atmel MCU Wireless. Description.

Wireless Security Camera

USER GUIDE EDBG. Description

DK40 Datasheet & Hardware manual Version 2

ULC Technology: High-performance gate array package using multiple metal layer CMOS technology featuring sub-micron channel lengths (0.

TURBO PROGRAMMER USB, MMC, SIM DEVELOPMENT KIT

What is Easy-Radio? Devices Covered. Frequency Hopping Transceiver. Where x00 denotes frequency of operation. E.g. 400 = 433MHz

WHQL Certification Approval...2 User Interface...3 SUNIX s COMLab..4

ET-BASE AVR ATmega64/128

ELAN DIGITAL SYSTEMS LTD. SL232 PC- CARD USER S GUIDE

Part 1. MAX BIT DAC with an Arduino Board. MIDI to Voltage Converter Part1

USB to serial chip CH340

Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science Microprocessor Project Laboratory

PFB366 Profibus-DP Gateway User Manual

UART IP Core Specification. Author: Jacob Gorban

Single channel data transceiver module WIZ2-434

Wireless Home Security System

2.8.3 / (Z80 Serial I/O)

Señal RS232. d. codevilla v1.0

Atmel Norway XMEGA Introduction

Microcontroller Based Low Cost Portable PC Mouse and Keyboard Tester

Eliminate Risk of Contention and Data Corruption in RS-485 Communications

Lab Experiment 1: The LPC 2148 Education Board

Manual Serial PCI Cards

COMPUTER HARDWARE. Input- Output and Communication Memory Systems

Programming Flash Microcontrollers through the Controller Area Network (CAN) Interface

Appendix A. This Appendix includes the following supplemental material:

WHQL Certification Approval...2 User Interface K software FIFO 4 Universal PCI Interface...5 Ready for 64-bit System...5

SyncLink GT2/GT4 Serial Adapter

Advanced Data Capture and Control Systems

OPT SERIAL TO FIBER OPTIC CONVERTER

[WIR-1186] 865MHz-869MHz Wireless Module(version 3.0) (3.3V)

16-Port RS232 to USB2.0 High Speed Multi Serial Adapter (w/ Metal Case) Installation Guide

PC Base Adapter Daughter Card UART GPIO. Figure 1. ToolStick Development Platform Block Diagram

HAC-LM Series Low Power Data Radio Module

RN-131-PICTAIL & RN-171-PICTAIL Evaluation Boards

LTM-1338B. Plus Communications Manual

LDG Electronics External Meter Serial Communications Protocol Specification

Display Message on Notice Board using GSM

DECT Module UM-9802 Datasheet

User s Manual of Board Microcontroller ET-MEGA2560-ADK ET-MEGA2560-ADK

Using the HT46R46 I/O Ports to Implement Half-Duplex SPI Communication

International Journal of Research in Advent Technology Available Online at:

The Analyst RS422/RS232 Tester. With. VTR, Monitor, and Data Logging Option (LOG2) User Manual

Industrial Multi-port Serial Cards

Accurate Measurement of the Mains Electricity Frequency

Am186ER/Am188ER AMD Continues 16-bit Innovation

PCI 2 Port Fast Serial Communication Adapter Card User Manual

AND8336. Design Examples of On Board Dual Supply Voltage Logic Translators. Prepared by: Jim Lepkowski ON Semiconductor.

Arduino Wifi shield And reciever. 5V adapter. Connecting wifi module on shield: Make sure the wifi unit is connected the following way on the shield:

How To Use A Sound Card With A Subsonic Sound Card

Future Technology Devices International Ltd

PCMCIA 1 Port RS EDITION OCTOBER 1999

Computer Performance. Topic 3. Contents. Prerequisite knowledge Before studying this topic you should be able to:

Virtual Integrated Design Getting started with RS232 Hex Com Tool v6.0

BIT COMMANDER. Serial RS232 / RS485 to Ethernet Converter

TTL-232R-3V3 USB to TTL Serial Converter Cable

2-Port RS232/422/485 Combo Serial to USB2.0 Adapter (w/ Metal Case and Screw Lock Mechanism) Installation Guide

A+ Guide to Managing and Maintaining Your PC, 7e. Chapter 1 Introducing Hardware

Introduction the Serial Communications Huang Sections 9.2, 10.2 SCI Block User Guide SPI Block User Guide

Part Number Description Packages available

ARM Thumb Microcontrollers. Application Note. Software ISO 7816 I/O Line Implementation. Features. Introduction

Stevens Cell-Net CDMA & GSM M2M 3G Data Modem. Product Manual

AVR151: Setup and Use of the SPI. Introduction. Features. Atmel AVR 8-bit Microcontroller APPLICATION NOTE

Serial Communications (Chapter 10) RS232, SPI, I2C

How to setup a serial Bluetooth adapter Master Guide

Bluetooth to Serial Adapter

RS - SPM. Serial parallel translator module

Application Note AN_243. FT312D USB Host to UART Cable Application

Quick Start Guide. MRB-KW01 Development Platform Radio Utility Application Demo MODULAR REFERENCE BOARD

Consult protocol, Nissan Technical egroup, Issue 6

Fast Ethernet and Gigabit Ethernet. Networks: Fast Ethernet 1

2-port RS-422 / 485 Universal PCI

Tutorial.

Chapter 13. PIC Family Microcontroller

Transcription:

The USART is used for synchronous and asynchronous serial communication. USART = Universal Synchronous/Asynchronous Receiver Transmitter Our focus will be on asynchronous serial communication. Asynchronous communication does not use a clock to validate data. Serial data is transferred one bit at a time. Asynchronous serial interfaces are cheap, easy to use, and until recently, very common. USB is well on its way to replace the serial comm ports on PCs. The USART communicates in a full-duplex mode (simultaneous xmit, rcv)

Serial frame format: Every frame will have at least -one start bit -some data bits (5,6,7,8 or 9) -one stop bit Parity is optional

How can two asynchronous devices communicate with each other? AVR1 16Mhz AVR2 16Mhz There is no known phase relationship between the two AVR boards How can a receiving board know where the center of a bit frame is? How can it know where the start bit is? start bit What do we need to know? 0 1 2 3

- Need to know how fast the bits are coming (baud rate) - Need to know where the start bit begins (its falling edge) - Then we know when to sample start bit 0 1 2 3 sample sample sample sample

- The USART uses a 16x internal clock to sample the start bit. The incoming data is continuously sampled until a falling edge is detected. Once detected, the receiver waits 6 clocks to begin sampling. One clock before the expected center of the start bit, 3 samples are taken. If 2 or 3 are detected as high, the search for another falling edge is started. If at least one sample is low, the start bit is validated. If so, begin sampling 16 clocks from center of start bit. Revalidate again with each data byte. Synchronization happens on each byte.

- The USART internal clock is set by the UBRR register. The internal clock is derived from the internal CPU clock. Both transmitter and receiver use the same clock to operate from. The transmitter is synchronous to the clock. In coming data to the receiver is not. The baud rates are not exact power of 2 multiples of the CPU clock, thus baud rate inaccuracies occur at some settings. This is why you see some "funny" crystal oscillator frequencies.

- Error detection -Parity -created by an XOR of the data bits -parity can be even or odd -P even = dn XOR dn-1 XOR dn-2... XOR d0 -P odd = dn XOR dn-1 XOR dn-2... XOR d0 XOR 1 If we have a data byte, 0b0010_1101 and we want odd parity, the parity bit is set to a one to make a total of 9 bits which is an odd number of 1's... i.e., odd parity Thus, the new data byte with parity is: 0b0010_1101 plus the parity bit 1 parity bit

- Error detection -Frame error -a frame error occurs when the receiver is expecting the stop bit and does not find it. -also known as a synchronization failure -the frame (byte) must be resent stop bit(s) -Data overrun error -data was not removed in the receive buffer before another byte came and overwrote it.

- USART Electrical path We use the RS-232 standard for communications to a PC. RS-232 specifies an inverted +/- 3 Volt interface. <= -3 volts is considered a 1 or mark >= +3 volts is considered a 0 or space -3V +3V

- USART RS232 transceiver -Charge Pump inverter used to generate negative voltages.

- USART Electrical path The mega128 board uses the MAX232 chip. It has an internal charge pump to generate the negative and positive voltages for the RS-232 interface. to port D The DB9 connector is standard for mating with a PC serial connector. The port D interface is shared with the IR LED I/O devices. They are inverted also so that an space signal does not keep the IR LED on (100mA). to port E

USART Electrical path -UART can be used with IR LED also.

Some useful USART Software Routines: // uart_init // //RXD0 is PORT E bit 0 //TXD0 is PORT E bit 1 //Jumpers J14 and J16 (mega128.1) OR //Jumpers J7 and J9 (mega128.2) //must be in place for the MAX232 chip to get data. // void uart_init(){ //rx and tx enable, 8 bit characters UCSR0B = (1<<RXEN0) (1<<TXEN0); //async operation, no parity, one stop bit, 8-bit characters UCSR0C = (1<<UCSZ01) (1<<UCSZ00); //set to 9600 baud UBRR0H=0x00; UBRR0L=0x67; }

Some useful USART Software Routines: // uart_putc // //Takes a character and sends it to USART0 // void uart_putc(char data){ while (!(UCSR0A&(1<<UDRE))); // Wait for previous transmission UDR0 = data; // Send data byte while (!(UCSR0A&(1<<UDRE))); // Wait for previous transmission } // uart_puts //Takes a string and sends each charater to be sent to USART0 //void uart_puts(unsigned char *str) { void uart_puts(char *str) { int i = 0; //Loop through string, send each char while(str[i]!= '\0'){uart_putc(str[i]); i++;} }

Some useful USART Software Routines: // uart_getc //Modified to not block indefinately in the case of a lost byte // char uart_getc(void) { uint16_t timer = 0; while (!(UCSR0A & (1<<RXC0))) { timer++; if(timer >= 16000) return 0; } // Wait for byte to arrive return UDR0; }