Serial I/O. 4: Serial I/O. CET360 Microprocessor Engineering. J. Sumey

Similar documents
Universal Asynchronous Receiver Transmitter Communication

1.1. INTRODUCTION 1.2. NUMBER SYSTEMS

EXPERIMENT 8: Introduction to Universal Serial Asynchronous Receive Transmit (USART)

EXPERIMENT 7: Introduction to Universal Serial Asynchronous Receive Transmit (USART)

Data Representation and Binary Arithmetic. Lecture 2

Sender Receiver Sender

Lecture 13 Serial Interfaces

A GUIDE TO RS-232 COMMUNICATION WITH FX PLCS

DATA REPRESENTATION. Data Types. Complements. Fixed Point Representations. Floating Point Representations. Other Binary Codes. Error Detection Codes

Fundamentals of Programming (C)

RS-422 Code-Operated Switches

plc numbers Encoded values; BCD and ASCII Error detection; parity, gray code and checksums

Mounting Dimensions / Viewing 2 Mounting Options 3. Wiring Configuration 4. Quick Set up Procedure 5. Changing Intensity 6.

S-Series Sensor ASCII Protocol v8.1.0

Serial Communication. Transmit. Receive To EECC250 - Shaaban. From Universal Asynchronous Receiver/Transmitter (UART) Parity Bit

FD-011WU. 2D Barcode Reader User Guide V1.6CC

Serial Interfaces Part 1. ECE 153B Sensor & Peripheral Interface Design Winter 2016

Chapter 3. Information Representation

CMSC 313 Lecture 03 Multiple-byte data big-endian vs little-endian sign extension Multiplication and division Floating point formats Character Codes

MK D Imager Barcode Scanner Configuration Guide

Chapter 11: Input/Output Organisation. Lesson 05: Asynchronous RS232C Serial Port data transfer

Positional Number System

PD1100 STAND-ALONE PROGRAMMING & USER S GUIDE. use the freedom

CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 02, FALL 2012

Select a Data Communication Interface

PS232. RS-232 to PS/2 Keyboard Port Adapter Part # SA0009 (Version 4.0) Copyright 2003 L3 Systems, Inc. Redmond

RS-232 Digital Relay I/O

2a. Codes and number systems (continued) How to get the binary representation of an integer: special case of application of the inverse Horner scheme

Chapter 2 Number System

1. Character/String Data, Expressions & Intrinsic Functions. Numeric Representation of Non-numeric Values. (CHARACTER Data Type), Part 1

2D BARCODE SCANNER CA-SC-20200B

Serial Interfacing. Asynchronous Frame

Bits and Bytes. Data Representation. A binary digit or bit has a value of either 0 or 1; these are the values we can store in hardware devices.

8051SERIAL PORT PROGRAMMING

Fundamentals of Programming

ADDMASTER. Addmaster Corporation. IJ-3080 Journal/Validation Printer. Specification. IJ-3080 Specification

Serial Communication Prof. James L. Frankel Harvard University. Version of 2:30 PM 6-Oct-2015 Copyright 2015 James L. Frankel. All rights reserved.

Addmaster Corporation

Serial Communication. Spring, 2018 Prof. Jungkeun Park

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON

Number Systems II MA1S1. Tristan McLoughlin. November 30, 2013

CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 02, SPRING 2013

PD1100 PASS-THROUGH PROGRAMMING & USER S GUIDE. use the freedom

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON

Characters Lesson Outline

4.3 Digital Communication

User s Manual. Xi3000 Scanner. Table of Contents

Xi2000-BT Series Configuration Guide

FEC-240G. Rev. Date

CS341 *** TURN OFF ALL CELLPHONES *** Practice NAME

Number System (Different Ways To Say How Many) Fall 2016

EE 109 Unit 3. Analog vs. Digital. Analog vs. Digital. Binary Representation Systems ANALOG VS. DIGITAL

PureScan - ML1. Configuration Guide. Wireless Linear Imager Wireless Laser scanner - 1 -

Menu & commands booklet FOR BAR CODE SCANNERS * *

Lecture (09) x86 programming 8

2D Barcode Reader User Guide V 1.2.1

Binary Numbers. The Basics. Base 10 Number. What is a Number? = Binary Number Example. Binary Number Example

ASCII Code - The extended ASCII table

KB232. PS/2 Keyboard RS-232 Adapter Part # SA0008 (Version 3.0) Copyright 2003 L3 Systems, Inc. Redmond

EE 109 Unit 2. Analog vs. Digital. Analog vs. Digital. Binary Representation Systems ANALOG VS. DIGITAL

ASSIGNMENT 5 TIPS AND TRICKS

n NOPn Unary no operation trap U aaa NOP Nonunary no operation trap i

CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 02, FALL 2012

Data Representa5on. CSC 2400: Computer Systems. What kinds of data do we need to represent?

Do not start the test until instructed to do so!

3170 Series Touch Screen POS Workstation

Data Representa5on. CSC 2400: Computer Systems. What kinds of data do we need to represent?

BARCODE SCANNER. Configuration Guide - 1 -

Configuration Manual PULSAR C CCD SCANNER. Table of Contents

Chapter 2 Bits, Data Types, and Operations

Lecture-65 SERIAL DATA COMMMUNICATION The data bus of a microcomputer system is designed to transfer data to and from I/O device in parallel - all

Number Representations

Data Communications & Computer Networks. Digital Data Communications Techniques

e-pg Pathshala Subject : Computer Science Paper: Embedded System Module: Serial Port Communication Module No: CS/ES/11 Quadrant 1 e-text

VIGOR PROGRAMMABLE LOGICAL CONTROLLERS VIGOR ELECTRIC CORP.

Connecting UniOP to Datalogic Barcode Readers

Customer Pole Display. Model: WD-304 Version: 1.12

NC-1200 BARCODE SCANNER. Configuration Guide - 1 -

Oberon Data Types. Matteo Corti. December 5, 2001

Chapter 8. Characters and Strings

Do not start the test until instructed to do so!

DB-II Serial Communication Protocol Revision 0.2(English)

Chapter 2 Bits, Data Types, and Operations

TABLE OF CONTENTS. Communication Functions

QTERM-J10/N15 USER'S MANUAL REVISION 13

Chapter 2 Bits, Data Types, and Operations

Chapter 9: Data Transmission

RS-232 DATA COMMUNICATIONS WITH THE TANDY COLOR COMPUTER

Datalogic Scanning, Inc. 959 Terry Street Eugene, Oregon Telephone: (541) Fax: (541)

Input-Output Organization

DS-800. ::: Receipt Printer User s manual :::

CPS 104 Computer Organization and Programming Lecture-2 : Data representations,

XR-200 MINI DOT IMPACT PRINTER PRODUCT SPECIFICATION DATE : MAY 3, 2004 MANUAL REVISION 2.0

COPYRIGHT 2009,SCSC. Manual P/No: SCCM - 80S-01A Released Date: Oct 31, 2009

Table of Contents Sleep Settings How to Configure the Scanner. 7 Chapter 2 System Setup

MOBILE THERMAL PRINTER

TSP552 TSP552II TSP2000

EE 109 Unit 2. Binary Representation Systems

Numbers and Computers. Debdeep Mukhopadhyay Assistant Professor Dept of Computer Sc and Engg IIT Madras

RS-232 Control of the Advantage EQ281/8, EQ282/8 and Advantage SMS200

Transcription:

4: Serial I/O CET360 Microprocessor Engineering J. Sumey Introduction serial, i.e. bit-at-a-time, interfacing techniques are useful when parallel interfacing limitations become problematic distance limitations due to crosstalk cabling costs was popularized in the 1960s by teletypes and modem technologies standardized as RS-232C in 1969 by the EIA used by many I/O peripherals mice, printers, digital cameras, PDAs, GPS receivers, POS terminals (cash drawers & scanners) predecessor to USB 2 CET360 Microprocessor Engineering 1

Serial Interface Components at a minimum, a serial interface requires: 1. transmit / receive registers holds parallel data before/after serialization 2. PISO/SIPO shift registers handles serialization/deserialization 3. clock circuitry (Baud rate generator) timing signals used by shift registers referred to as UARTs or SCI Universal Asynchronous Receiver/Transmitter Serial Communication Interface (Motorola) also: COM ports on PCs 3 Example: Coldfire/S12 SCI 4 CET360 Microprocessor Engineering 2

Serial Data Transmission Issues a pair of devices communicating over a serial link must agree on a number of parameters 1. communication type 2. data coding 3. transmission (Baud) rate 4. clocking method 5. error handling 6. handshaking 5 1 Communication Type refers to how the 2 devices communicate with each other a. simplex fixed, 1-way over a single channel b. half-duplex 2-way over a single, shared (unidirectional but reversible) channel c. full-duplex 2-way over a pair of unidirectional channels 6 CET360 Microprocessor Engineering 3

2 Data Coding choice of binary code used to represent alphanumeric data ASCII American Standard Code for Information Interchange EBCDIC Extended Binary Coded Decimal Interchange Code (IBM) proprietary ex: credit card scanner also may refer to the logic levels used 1=mark, 0=space 7 Hex 0 1 2 3 4 5 6 7 0 NUL DLE 0 @ P ` p 1 SOH DC1! 1 A Q a q 2 STX DC2 2 B R b r 3 ETX DC3 # 3 C S c s 4 EOT DC4 $ 4 D T d t 5 ENQ NAK % 5 E U e u 6 ACK SYN & 6 F V f v 7 BEL ETB 7 G W g w 8 BS CAN ( 8 H X h x 9 HT EM ) 9 I Y i y A LF SUB * : J Z j z B VT ESC + ; K [ k { C FF FS, < L \ l D CR GS - = M ] m } E SO RS. > N ^ n ~ F SI US /? O _ o DEL KEY NUL = Null SOH = Start Of Header STX = Start of Transmission ETX = End of Transmission EOT = End of Text ENQ = Enquiry ACK = Acknowledge BEL = Audible Bell BS = BackSpace HT = Horizontal Tab LF = Line Feed VT = Vertical Tab FF = Form Feed CR = Carriage Return SO = Shift Out SI = Shift In DLE = Data Link Escape DCx = Device Control x NAK = Negative Acknowledge SYN = Synchronization char. ETB = End Transmission Block CAN = Cancel EM = End of Medium SUB = Substitute ESC = Escape FS = Field Separator GS = Group Separator RS = Record Separator US = Unit Separator DEL = Delete CET360 Microprocessor Engineering 4

3 Baud Rate speed at which bits (per sec.) are sent over a serial data link may (asynchronous) or may not (synchronous) include overhead bits bit time 1 baud rate also: bit rate = number of data bits per sec. common baud rates: 110, 300, 1200, 2400, 4800, 9600, 19.2k, 38.4k 9 4 Clocking Method determines how receiver is synchronized to transmitter synchronous same clock source is either sent along with or encoded within a continuous data stream, ex: Ethernet LAN bit rate = baud rate asynchronous no common clock, Tx & Rx run from separate clocks data bits are framed with Start/Stop bits Start bit: a fixed 0 bit prefixing the data bits Stop bit: a fixed 1 bit suffixing the data bits bit rate < baud rate (because of overhead) 10 CET360 Microprocessor Engineering 5

Asynchronous Format line is held in inactive mark state (1) when no data to send data bits are sent/received LSB to MSB characters may be sent back-to-back but not a requirement! ex 2 chars using 8 data, 1 stop, no parity: challenge: show waveform for the message Hi 11 5 Error Handling deals with how errors are detected and/or corrected parity each sent character may have an odd or even parity bit added to it, directly before the stop bit based on the total number of 1s in the character (including parity bit) used for simple error detection, only 50% accurate checksum better method based on 1 s complement of binary sum 8-bit performance: 255/256 accuracy, also 16-bit, 32-bit cyclic redundancy check (CRC) more sophisticated error detection mechanism based on polynomial math, 99.99%+ accurate 12 CET360 Microprocessor Engineering 6

Checksum Calculation /* * checksum8: calculate & return 8-bit checksum of data array * p: pointer to beginning of data byte "array" * len: array length in bytes * returns: 8-bit 1's complement checksum of array */ byte checksum8(void *p, int len) { byte *q = p; // so p can point to anything byte sum = 0; // running sum for (; len>0; --len) // iterate over each byte in array sum += *q++; // add byte value to running sum return (byte)~sum; // return 1's comp of sum } 13 6 - Handshaking additional control interface signals RTS/CTS Request To Send/Clear To Send DTR/DSR Data Terminal Ready/Data Set Ready DCD Data Carrier Detect RI Ring Indicate used to control / throttle the transmitter may be optional depending on hardware and software implementation 14 CET360 Microprocessor Engineering 7

Serial Communication Standards a number of industry-wide serial standards are commonly used, some have been defined by the Electronic Industries Alliance (EIA) 20/60ma current loop T.T.L. RS-232C (1969) RS-423 EIA-423 RS-422 EIA-422 RS-485 EIA-485 USB SATA 15 Serial Standards 20/60ma current loop original standard used by teletypes I=1, no I=0 once popular in (noisy) industrial settings T.T.L. simple, logic-level based +5VDC=1, 0VDC=0 good for on-pcb device-to-device transfer, otherwise not useful for much distance due to noise vulnerability 16 CET360 Microprocessor Engineering 8

RS-232C Standard defines many characteristics of a serial interface 20 signal names & functions: TxD, RxD, RTS, CTS, etc. connectors & pinouts: DB-25, DE-9, RJ-45 cable specs upto 20kbps upto 50 voltage levels 1=mark=off=-3..-25V, 0=space=on=+3..+25V notice avoidance of ground level! 17 RS-232C Standard classifies devices as being either: Data Terminal Equipment (DTE) or Data Communication Equipment (DCE) defines which pins transmit, receive, etc. requires interface drivers to convert logic levels ex: Maxim s MAX232 http://datasheets.maxim-ic.com/en/ds/max220-max249.pdf 18 CET360 Microprocessor Engineering 9

MAX232/MAX232A 5V Supply! Charge Pump Inverter Logic side EIA side 19 RS-232C Pinouts* Signal Name DB-25 DE-9 Transmitted Data TD 2 3 Received Data RD 3 2 Request To Send RTS 4 7 Clear To Send CTS 5 8 Data Set Ready DSR 6 6 Common Ground G 7 5 Carrier Detect DCD 8 1 Data Terminal Ready DTR 20 4 Ring Indicator RI 22 9 *with respect to DTE device 20 CET360 Microprocessor Engineering 10

EIA-423 Standard an improved version of RS-232 using highperformance drivers and receivers single-ended / unbalanced like RS-232 but with better performance provides up to 100 kbps and up to 4000' supports multi-drop connections up to 10 receivers on a single line 21 EIA-422 Standard similar to EIA-423 but with even better performance provides up to 10 Mbps and upto 4000' eliminates ground loop problems by transmitting bits as a voltage difference over a unidirectional wire pair has a very high common mode rejection ratio (CMRR) works better with long cable runs Note: Ethernet LANs work the same way! great for use as an RS-232 extender 22 CET360 Microprocessor Engineering 11

EIA-422 Example RS-422 4-wire network using balanced differential drivers (generators) and receivers 23 EIA-485 Standard similar to EIA-422 but allows multiple receivers and drivers (up to 32 each) to share a single 2-wire differential pair in half-duplex fashion thus, is multi-point readily supports low-cost local networking ex: PLCs on factory floors, home/building automation provides up to 35 Mbps and up to 4000' 24 CET360 Microprocessor Engineering 12

EIA-485 2-wire Network Example 25 Universal Serial Bus (USB) similar to EIA-422 (half-duplex, differential), but uses communication protocols to packetize data transfers used by current PCs to support connection of modern peripherals supports upto 127 devices, upto 16 4 different transfer speeds low speed (1.0) = 1.5Mbps full speed (1.1) = 12Mbps hi speed (2.0) = 480Mbps superspeed (3.0) = 4.8Gbps 26 CET360 Microprocessor Engineering 13

References Wikipedia Articles: http://en.wikipedia.org/wiki/current_loop http://en.wikipedia.org/wiki/rs-232 http://en.wikipedia.org/wiki/rs-485 RS-232 tutorial: http://www.radio- electronics.com/info/telecommunications_networks/rs232/rs232- serial-interface-basics-tutorial.php B&B Electronics RS-422 & RS-485 App Note: http://www.bb-elec.com/bb-elec/literature/tech/485appnote.pdf Maxim MAX-232 IC: http://datasheets.maxim-ic.com/en/ds/max220-max249.pdf 27 CET360 Microprocessor Engineering 14