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



Similar documents
Serial Communications

INFORMATICA INDUSTRIALE

INFORMATICA INDUSTRIALE

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

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

Serial Communications

USART and Asynchronous Communication

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

Using Xbee in Serial Communication

Application Note 83 Fundamentals of RS 232 Serial Communications

Section 17. UART HIGHLIGHTS UART. This section of the manual contains the following major topics:

UART IP Core Specification. Author: Jacob Gorban

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

RS-232 COMMUNICATIONS

CENTRONICS interface and Parallel Printer Port LPT

Software User Guide UG-461

RS232C < - > RS485 CONVERTER S MANUAL. Model: LD15U. Phone: / 97 / 98 (M)

Develop a Dallas 1-Wire Master Using the Z8F1680 Series of MCUs

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

RS232 Board datasheet

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

Single channel data transceiver module WIZ2-434

a8251 Features General Description Programmable Communications Interface

TCP/IP MODULE CA-ETHR-A INSTALLATION MANUAL

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

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

UMBC. ISA is the oldest of all these and today s computers still have a ISA bus interface. in form of an ISA slot (connection) on the main board.

PCMCIA 1 Port RS EDITION OCTOBER 1999

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

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

MCB3101 (Class I) WiRobot Serial Bluetooth Wireless Module User Manual

USER GUIDE EDBG. Description

Manual Serial PCI Cards

USB2.0 <=> I2C V4.4. Konverter Kabel und Box mit Galvanischetrennung

Señal RS232. d. codevilla v1.0

PFB366 Profibus-DP Gateway User Manual

COMPUTER HARDWARE. Input- Output and Communication Memory Systems

Data Cables. Schmitt TTL LABORATORY ELECTRONICS II

Advanced Data Capture and Control Systems

USB TO SERIAL ADAPTER

DK40 Datasheet & Hardware manual Version 2

1.Eastron SDM220Modbus Smart Meter Modbus Protocol Implementation V1.0

DECT Module UM-9802 Datasheet

Microcomputer Protocol Implementation at Local Interconnect Network Georgi Krastev

LDG Electronics External Meter Serial Communications Protocol Specification

SC16C652B. 1. General description. 2. Features. 5 V, 3.3 V and 2.5 V dual UART, 5 Mbit/s (max.) with 32-byte FIFOs and infrared (IrDA) encoder/decoder

Cable Guide. Click on the subject to view the information. Digi Cables Building Cables General Cable Information

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

Microprocessor & Assembly Language

Fondamenti su strumenti di sviluppo per microcontrollori PIC

Section 14. Compare/Capture/PWM (CCP)

Bluetooth to Serial Adapter

ENET-710. ENET Ethernet Module ENET-710 JAN / 06 FOUNDATION

Modification of an AOR AR-8600 receiver to tune it with a ACECO FC-3002 frequency finder

Toshiba Serial Driver Help Kepware Technologies

SUDT AccessPort TM Advanced Terminal / Monitor / Debugger Version 1.37 User Manual

Managing High-Speed Clocks

The Secrets of Flow Control in Serial Communication

MDM192 MULTI-DROPS DIGITAL MODEM FOR PRIVATE LINE. USER GUIDE Document reference :

Design and Implementation of Home Monitoring System Using RF Technology

LINDY ELECTRONICS LIMITED & LINDY-ELEKTRONIK GMBH - SECOND EDITION

Programming and Using the Courier V.Everything Modem for Remote Operation of DDF6000

When we look at the connector pinout of the RS232 port, we see two pins which are certainly used

ALL-USB-RS422/485. User Manual. USB to Serial Converter RS422/485. ALLNET GmbH Computersysteme Alle Rechte vorbehalten

2 Basic Concepts. Contents

The I2C Bus. NXP Semiconductors: UM10204 I2C-bus specification and user manual HAW - Arduino 1

Objectives. Lecture 4. How do computers communicate? How do computers communicate? Local asynchronous communication. How do computers communicate?

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

Why you need to monitor serial communication?

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

Hello, and welcome to this presentation of the STM32 Serial Audio Interface. I will present the features of this interface, which is used to connect

Multiple clock domains

Chapter 02: Computer Organization. Lesson 04: Functional units and components in a computer organization Part 3 Bus Structures

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

2.8.3 / (Z80 Serial I/O)

FOSTCDR. Industrial Serial to Multimode Fiber Optic Converter PRODUCT INFORMATION B&B ELECTRONICS. Specifications Serial Technology

T3 Mux M13 Multiplexer

NMEA 0183 INSTALLATION AND OPERATING GUIDELINES

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

Lab Experiment 1: The LPC 2148 Education Board

NTE2053 Integrated Circuit 8 Bit MPU Compatible A/D Converter

Displaying a Numerical Value on HyperTerminal (or equ.)

PM1122 INT DIGITAL INTERFACE REMOTE

INTERNATIONAL TELECOMMUNICATION UNION

DS1104 R&D Controller Board

Software Manual RS232 Laser Merge Module. Document # SU Rev A

Modbus Communications for PanelView Terminals

Using FPGAs to Design Gigabit Serial Backplanes. April 17, 2002

EVAL-UFDC-1/UFDC-1M-16

Fast Ethernet and Gigabit Ethernet. Networks: Fast Ethernet 1

4Links. Half-Duplex SpaceWire. Barry M Cook, Paul Walker. 4Links Limited Bletchley Park MK3 6EB UK SpW-WG12 1

Measuring Resistance Using Digital I/O

LOW COST GSM MODEM. Description. Part Number

Current Loop Application Note 1495

RS-232 Baud Rate Converter CE Model 232BRC Documentation Number 232BRC-3903 (pn5104-r003)

POS Integration. Prepared by: Binh Nguyen

Modicon Modbus Protocol Reference Guide. PI MBUS 300 Rev. J

Measurement and Analysis Introduction of ISO7816 (Smart Card)

Hello, and welcome to this presentation of the STM32 SDMMC controller module. It covers the main features of the controller which is used to connect

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

Transcription:

Parallel IO Parallel IO data sent over a group of parallel wires. Typically, a clock is used for synchronization. D[15:0] clk Serial IO Serial IO data sent one bit at a time, over a single wire. A clock may or may not be used for synchronization D clk A 16-bit data channel is shown above. If data is transferred each rising clock edge, and clock rate is 300 MHz, then the data transfer rate (bandwidth) in bytes/sec is: 2 Bytes/clock period = 2 /(1/300e06)s = 2 300e06/s = 600e06/s = 600 MB/s (MB = MBytes) V 0.2 1 Question: Assuming one bit is sent each rising clock edge, how fast does the clock have to be achieve 600 MB/s? 600 MByte/s = 600 MBytes/s 8 bits/1byte = 4800Mb/s Clock period = 1/4800e06 Clock Frequence = 1/clock period = 4800e06 = 4.8e09 = 4.8GHz V 0.2 2 Parallel IO Pros/Cons Pros: Speed, can increase bandwidth by either making data channel wider or increasing clock frequency Cons: Expensive (wires cost money!). Short distance only long parallel wire causes crosstalk, data corruption. Parallel vs. Serial IO Serial IO Pros/Cons Pros: Cheap, very few wires needed. Good for long distance interconnect. Cons: Speed; the fastest serial link will typically have lower bandwidth than the fastest parallel link. However, for long distances (meters), new fast serial IO standards (USB2, Firewire) have replaced older parallel IO Full-duplex: communication in both directions at same time. V 0.2 4 standards. V 0.2 3 simplex vs half-duplex vs full-duplex For communication channels simplex: communication in one direction only or Half-duplex: communication in either direction, but only one way at a time Wires: Simplex, Half-duplex For wires: simplex wire: communication occurs only in one direction. Wires: Full Duplex Current mode signaling allows full duplex communication over a single wire. Used for communication in some advanced chipsets. uni-directional ia + ib half-duplex wire: communication can occur in either direction, but with voltage signaling only one direction at a time. Oe bi-directional Oe V 0.2 5 ia = ib - + ia ia + ib Currents add, voltages do not! ib ia + ib ib - = ia + V 0.2 6 1

Synchronous Serial IO Synchronous Serial IO Channel Internal clock frequencies match to within a tolerance value. Can be out of phase Synchronous serial IO either (a) sends the clock as a separate wire OR (b) receiver () extracts clock from data stream or uses a Phase- Locked-Loop (PLL) and changes in the data stream to synchronize internal clock (phase alignment) to data stream. For PLL synchronization, the data line must be guaranteed to have a minimum number of state changes (0 1 or 1 0) within a particular time interval (transition density). Synchronous serial IO can achieve high speeds; all new high speed serial standards are synchronous. V 0.2 7 Asynchronous Serial IO Asynchronous Serial IO Channel Internal clock frequencies match to within a tolerance value. Can be out of phase Asynchronous Serial I/O does not transmit the clock on a separate wire nor does it guarantee a particular transition densisty (ie., the data line could remain in the same state, either 1 or 0 for the duration of the transmission after the initial state change indicating start of transmission). Asynchronous Serial I/O is used in older standards, is easy to implement, but is slower than synchronous serial standards. V 0.2 8 A Three-Wire Async Serial Interface We will use a three-wire asynchronous serial interface to connect the PIC to an external PC. This interface standard is known as RS-232 (there are more wires defined in the standard, we will only use 3 wires) :transmit, :Receive gnd gnd Each wire is simplex, but communication channel is full duplex V 0.2 9 Asynchronous Serial Data Frame 10 bits 7E1 (7 data bits, even parity, 1 stop bit) D 0 D 1 D 2 D 3 D 4 D 5 D 6 P D 0 D 1 10 bits 8N1 (8 data bits, no parity, 1 stop bit) D 0 D 1 D 2 D 3 D 4 D 5 D 6 D 7 D 0 D 1 Mark A Constant Logic-1 Denoted by Space A Constant Logic-0 Standard is for Serial Line to CONSTANTLY be Driven to a MARK While Inactive start bit 1 ASCII char. = 7 bits D 0 LSB (e.g. DEL = 7fh higher is PC specific) D 6 (D 7 ) MSB Typical is 10 bits for asynchronous transfer P parity bit Serial data with even/odd parity - stop bit a mark Serial Data Receiver Starts Processing When: 1) high to low is sensed (start bit detection) 2) following (7 or 8) bits represent a character 3) parity bit for error detection 4) stop bit is detected (a mark ) slide by Prof. Mitch Thornton V 0.2 10 1 1 0 start bit data values Example 0 1 1 0 1 0 1 0 1 1 1 56h = V ASCII Character - stop bit a mark P even parity bit When Receiver sees a Start Bit (high to low transition): 1) Local Timer Starts 2) Each bit sampled at midpoint in time (± % clock tolerance) 3) Maximum tolerance is ± ½ of 1 bit time interval over 10 intervals = (½)/10 = 5% slide by Prof. Mitch Thornton V 0.2 11 Parity A parity bit is an extra bit added to a data frame to detect a single bit error A single bit error is when one bit of the frame was received incorrectly (read as 0 when should have been 1, or vice-versa). Not guaranteed to detect multi-bit errors Odd parity parity bit value makes the total number of 1 bits in the frame odd For 7-bit data value 0x56 (1010110), odd parity bit = 1 Even parity parity bit value makes the total number of 1 bits in the frame even For 7-bit data value 0x56 (1010110), even parity bit = 0 V 0.2 12 2

Receiver Sampling one bit time next bit 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 1 2 3 4 sample here Receiver clock; period usually either 64x or 16x bit time (above is 16x). At start bit, internal 4-bit counter set to 0. Sample at mid-point of bit time (counter value 7 or 8, some receivers sample at 7,8 and 9 and only accept bit if all values are the same do this for glitch rejection). Receiver/Transmitter clocks not perfectly matched. Our tolerance is ½ bit time (50%) spread over entire frame. Assuming a 10 bit frame, maximum mismatch between / clocks is 50%/10 = 5%, Baud Rate vs Bits Per Second Baud rate is the rate at which signaling events are sent Bits per second (bps) is the number of bits transferred per second (any type of bits, data or overhead bits) If only a 1 or 0 is sent for each signaling event, then baud rate = bps However, could use a signaling protocol that transfers multiple bits per signaling event i.e., use 4 different voltage levels, send two bits of data per signaling event (00 = -15v, 01= -5v, 10=+5v, 11 = 5v). In this case, bit rate will be double the baud rate The effective data rate is the rate at which data is transferred, minus the overhead bits (ie. start and stop bits). V 0.2 13 V 0.2 14 Baud Rate 115200 57600 38400 19200 9600 4800 1200 Common Baud Rates Divisor for 14.7456 MHz 128 256 512 1024 2048 4096 16384 The PIC oscillator is divided down in order to provide the / clocks. The divisor values on the right show that the commonly-used baud rates are even multiples of 14.7456MHz. This means these baud rates can be accurately reproduced by the PIC using this external oscillator frequency. V 0.2 15 Software-driven Serial I/O RB2 RB3 RB3 RB2 Can implement a serial link via software subroutines. Must be able to implement software delay loops that can accurately delay for 1-bit time. Does not require extra hardware on part of µp, but the processor operation is consumed by the send/receive operation. This approach is not-so-fondly referred to as bit-banging. V 0.2 16 / assume RB2 is line and is already a 1 / void putch(c) char i; bitclear(portb,2); delay_1bit(); for(i=0;i<8;i++) if (bittst(c,0)) bitset(portb,2); else bitclr(portb,2); delay_1bit(); c = c >> 1; bitset(portb,2) delay_1bit(); putch(c) putch(c) -- send one character over software serial link send start bit send 8-data bits, this does parallel-to-serial conversion Check LSB value, send 0 or 1 right shift to send LSB to MSB send stop bit, leave line in 1 condition V 0.2 17 / assume RB3 is line / unsigned char getch() c = 0x00; while(bittst(portb,3)); delay_onehalf_bit(); for(i=0;i<8;i++) delay_1bit() if (bittst(portb,3)) c = c 0x80; if (i!= 7) c = c >> 1; return(c); getch() getch() -- receive one character over software serial link Wait for start bit Wait until middle of bit time Input bit was 1, set MSB. Right shift as bits are sent LSB to MSB V 0.2 18 3

PIC16F873 USART USART Universal Synchronous Asynchronous Receiver Transmitter Hardware module in PIC that implements both synchronous and asynchronous serial IO. We will use asynchronous mode. Frees the processor from having to implement software delay loops; receive/transmit done by USART while processor can do other tasks. 16F873 Will always use 8-bit, no parity for PIC serial IO. USART TXREG RCREG RC6/TX RC7/RX USART Registers RCREG holds a received character; read this to get character TXREG write to this register to send a character RCSTA contains status bits for received character SPBRG and TXSTA control baud rate TXSTA status bits also select between async/sync IO, enable TX transmission PIR1 register contains status bits TXIF (transmit interrupt flag), 1 if TXREG is empty RCIF (receive interrupt flag), 1 if RCREG is full V 0.2 19 V 0.2 20 RCIF, TXIF Bits Transmit Hardware TXREG is double-buffered. If TSR is empty, after write to TXREG, then TXREG transferred to TSR and TREG empty again (TXIF = 1). Do not have to wait for last character to be sent before writing new character. Will be a 1 when RCREG has a character. Wait until RCIF=1, then read RCREG to get received character. Will be a 0 if TXREG is full (last character written to TXREG has not been sent yet). Wait until TXREG=1, then write character to TXREG V 0.2 21 Data sent LSB to MSB Output Shift register, TXREG is buffer register V 0.2 22 Receive Hardware RCREG is also a buffered register via 2 deep FIFO. This gives the processor more freedom in how fast it responds to received characters. Two-deep FIFO. Can hold 2 characters, while 3 rd character is being shifted into RSR register. V 0.2 23 / return 8 bit char from Receive port / getch()/putch() (USART) unsigned char getch () / wait until character is received / / while (!RCIF) / while (!bittst(pir1,5)); c = RCREG; return(c); / send 8 bit char to Transmit port / void putch (c) / wait until transmit reg empty / / while (!TXIF) / while (!bittst(pir1,4)); TXREG = c; These subroutines much simpler than software-based serial I/O. The putch/getch single character functions is used by the library function printf(). V 0.2 24 4

Baud Rate Control The baud rate is controlled by the 8-bit value in the SBPRG register and the BRGH bit (bit 2 in TXSTA register). Baud_Rate = Fosc/ [K(SBPRG+1)] or SBPRG = (Fosc/[KBaud_Rate] ) 1 Baud Rate Examples Desired baud rate of 9600, Fosc = 14.7456 MHz What is SBPRG value for high speed mode? SBPRG = (14.7456e06/[169600] ) 1 = 95 K = 16 if BRGH = 1 (high speed mode), then K = 16 K = 64 if If BRGH = 0 (low speed mode) What is SBPRG value for low speed mode? SBPRG = (14.7456e06/[649600] ) 1 = 23 V 0.2 25 V 0.2 26 Enabling Async Serial IO 1. Configure serial port pins (RC6/TX, RC7/RX) via SPEN bit (RCSTA:7 =1). To be on the safe side, also set TRISC7=0, TRISC6 =0, setting RC7, RC6 of the parallel port logic to inputs. 2. Select high or low speed baud rate via BRGH bit (bit 2) of TXSTA register 3. Select async mode SYNC bit (TXSTA:4 = 0) 4. Select 8-bit transmit via TX9 bit (TXSTA:6 = 0) 5. Select 8-bit receive via RX9 bit (RCSTA:6 = 0) 6. Enable transmit port via TXEN bit (TXSTA:5 = 1) 7. Enable receive port via CREN bit (RCSTA:4 = 1) V 0.2 27 Example C code to Enable Serial I/O / setup Async communication / bitset(rcsta, 7); / serial port enable / bitset(trisc, 7); / RC7 input / bitset(trisc, 6); / RC6 input / bitset(txsta, 2); / high speed mode / SPBRG = 95; / 9600 baud, high speed mode / bitclr(txsta, 4); / async mode / bitclr(txsta, 6); / 8-bit transmit / bitclr(rcsta, 6); / 8-bit reception/ bitset(txsta, 5); / transmit enable/ bitset(rcsta, 4); / enable receive / At this point, ready to call getch()/putch() to perform serial IO. V 0.2 28 Receive Error Conditions FERR bit (RCSTA:2) is set when a framing error is detected A framing error occurs when a STOP bit is detected as a 0 value. This happens is actual baud rate slower than expected baud rate. OERR bit (RCSTA:1) is set when an overrun error is detected Waited too long to read RCREG and FIFO fills up Set when stop bit of 3 rd byte is detected (2 bytes in FIFO, and 3 rd byte is shifted in) All receive activity is stopped; to reset, clear CREN (RCSTA:4), then set CREN. V 0.2 29 16F873 RC7/RX RC6/TX 0v to 5v logic levels Note logic inversion PIC to PC Serial IO Connection Tin MAX232 Rout Rin Tout EIA RS232 voltage levels logic 0 : +3v to +25v logic 1 : 3v to 25v TX Pin 3 Gnd Pin 5 RX Pin 2 DB9 Female serial cable connected to COM port on PC V 0.2 30 5

What is EIA-RS232? An interface standard originally used to connect PCs to modems A modem is a device used to send digital data over phone lines The standard defines voltage levels, cable length, connector pinouts, etc There are other signals in the standard beside TX, RX, Gnd The other signals are used for modem control (Data Carrier Detect, Ring Indicator, etc) and flow control (flow control signals are used to determine if a device is ready to accept data or not) We will not cover the other signals in the RS232 standard V 0.2 31 MAXIM 232/232A RS232 driver/receiver Converts RS232 voltage levels to digital levels and vice-versa External capacitors used with internal charge pump circuit to produce +/- 10V from 5V supply V 0.2 32 Hyperterminal Will use Hyperterminal program on PC to communicate with PIC. Under Programs Accessories Communications Hyperterminal When configuring Hyperterminal connection, must know port number (COM1/COM2/etc), baud rate, data bits (8), parity (none), stop bits (1), and flow control(none) On PC lab machines, use COM1 Very important to set flow control to none since we are only using a 3-wire connection and not using the handshaking lines in the RS232 standard. If you forget this, then will not receive any characters. V 0.2 33 What do you have to know? Difference between async/sync serial IO Format of async serial IO frames Details of PIC 16F873 USART operation for asynchronous IO Definitions of simplex, half-duplex, full-duplex What is meant by RS-232 and the need for voltage conversion between RS-232 and digital levels PIC16F873 to PC serial port interfacing V 0.2 34 6