1 מעבדה במבוא לתקשורת מועבר ע ” י דני סיטרון כל החומר על הקורס ( החומר שיילמד, תרגילים, ציונים, שעות קבלה …) נמצא ב :

Slides:



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

INPUT-OUTPUT ORGANIZATION
11-1 ECE 424 Design of Microprocessor-Based Systems Haibo Wang ECE Department Southern Illinois University Carbondale, IL I/O System Design.
1 Homework Reading (linked from my web page) –S and S Extracts –National Semiconductor UART Data Sheet Machine Projects –mp2 due at start of class 12 Labs.
SCI: Serial Communications Interface Presented by: Sean Kline Chad Smith Jamie Cruce.
DATA COMMUNICATIONS Some organisations concerned with standards: EIA - Electroonic Industries Association (RS standards including RS-232) IEEE - Institute.
Interfacing The Serial/RS-232 Port Hardware Serial Port Registers Programming.
Serial I/O - Programmable Communication Interface
1 Fall 2005 Local Serial Asynchronous Communication Qutaibah Malluhi Computer Science and Engineering Qatar University.
Hierarchy of I/O Control Devices
Asynchronous Communication Hardware  Data within a DTE is usually stored and moved in a parallel fashion.  Data sent across the channel is generally.
Spring EE 316 Computer Engineering Junior Lab Serial Ports.
Spring EE 316 Computer Engineering Junior Lab LCD modules, PROMs, Serial Ports.
Eng. Husam Alzaq The Islamic Uni. Of Gaza
COMP3221: Microprocessors and Embedded Systems
7-1 Digital Serial Input/Output Two basic approaches  Synchronous shared common clock signal all devices synchronised with the shared clock signal data.
EET Advanced Digital Chapter 21 Serial Ports.
Input/Output and Communication
1 The 9-Pin Connector Pin abbreviations (numbers in parentheses are the 25D pin numbers): 1. CD (8) 2. RD (Rx) (3) 3. TD (Tx) (2) 4. DTR (20) 5. SG (Ground)
ECE 371- Unit 11 Introduction to Serial I/O. TWO MAJOR CLASSES OF SERIAL DATA INTERFACES ASYNCHRONOUS SERIAL I/O - USES “FRAMING BITS” (START BIT AND.
1 מעבדה במבוא לתקשורת בהתאם לאמונה שלי שתלמיד שאינו שולט באנגלית לא יכול להתהדר בתואר אקדמי במדעי המחשב, אזי : זה השקף האחרון בעברית שתראו בקורס.
INPUT-OUTPUT ORGANIZATION
Embedded Systems Design
University of Tehran 1 Interface Design Serial Communications Omid Fatemi.
Technology Training that Works Hands of Data Communications, Networking & TCP/IP Troubleshooting.
Serial Communication ETEC 6416.
Transmission Modes Serial Transmission  One bit is transmitted on a circuit at a time  Usually there is one transmit circuit and one receive circuit.
Computers in Surveying SVY2301 / E4006 Automated Surveying.
The 8051 Microcontroller and Embedded Systems
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),
UART and UART Driver B. Ramamurthy.
Lecture 7 Universal Asynchronous Receiver/Transmitter (UART) NCHUEE 720A Lab Prof. Jichiang Tsai.
Modems Chapter 17. Basic Knowledge  Modems are little devices to use the telephone to talk to other computers.  Modem is an abbreviation for Modulator/
Universal Synchronous/Asynchronous Receiver/Transmitter (USART)
CSE466 Autumn ‘00- 1 Music Format if amp = 0, note is a command switch(note) 0: turn off specified channel 1: continue for specified tne w/ no change else.
“Describe the overview of hardware interfacing and the serial communication interface. Describe the PIC18 connections to RS232. Explain the serial port.
Universal Asynchronous Receiver/Transmitter (UART)
Microprocessors 2 lesson Subjects lesson 7 Planning Interrupts Serial communication /USART Questions.
CHAPTER SERIAL PORT PROGRAMMING. Basics of Serial Communication Computers transfer data in two ways: ◦ Parallel  Often 8 or more lines (wire conductors)
Serial Communications
Scott Baker Will Cross Belinda Frieri March 9 th, 2005 Serial Communication Overview ME4447/6405.
DEVICES AND COMMUNICATION BUSES FOR DEVICES NETWORK
Advanced Microprocessor1 I/O Interface Programmable Interval Timer: 8254 Three independent 16-bit programmable counters (timers). Each capable in counting.
 8251A is a USART (Universal Synchronous Asynchronous Receiver Transmitter) for serial data communication.  Programmable peripheral designed for synchronous.
EE 316 Computer Engineering Junior Lab Serial Ports, LCD Displays & PROMs.
Universal Asynchronous Receiver/Transmitter (UART)
CSE466 Autumn ‘00- 1 What’s Coming  Hardware  Basic Filters and Noise Management  Serial Communications  Design Meeting  Move the quiz up to Monday.
1 Transmission of Digital Data : Interface and Modems.
Digital Interfaces An interface links two devices Interface Standards define: – mechanical specifications - how many wires & connector type –electrical.
1 מעבדה במבוא לתקשורת מועבר ע ” י אליעזר גנסבורגר ( מעובד מחומר שנלקט ע " י דניאל סיטרון ) כל החומר על הקורס ( החומר שיילמד, תרגילים, ציונים, שעות קבלה.
Example 1 Program the divisor Latch for 300 baud. Assume Xin=1.8432MHz The Base Address: 0x3F8 0RX_TX / Divisor.low 1IER: Interrupt Enable Reg. / Divisor.high.
8251 USART.
BASICS OF SERIAL COMMUNICATIONS BIRLA VISHWKARMA MAHAVIDYALAYA ELECTRONICS & TELECOMMUNICATION DEPARTMENT PRESENTING BY: ABHISHEK SINGH AMANDEEP.
Lecture 15. Modem Controller Register 4310 DTR 0 = Polling Operator 1 = Interrupts Enabled RTS 1 =Self Test 0 =Normal.
NARNARAYAN SHASTRI INSTITUTE OF TECHNOLOGY Prepared by: Wasu Ichcha kaur H Bhalani Nidhi M Dhakate Megha D MICROCONTROLLER.
Lecture # 14. RS – 232C Standard Standard for physical dimensions of the connectors. PC (DTE) Modem RS – 232C Cable Connected via serial port (DCE)
Serial mode of data transfer
RS-232 Communications.
CS-401 Computer Architecture & Assembly Language Programming
Homework Reading (linked from my web page) Machine Projects Labs
SERIAL PORT PROGRAMMING
1 Input-Output Organization Computer Organization Computer Architectures Lab Peripheral Devices Input-Output Interface Asynchronous Data Transfer Modes.
RS-232 Communications.
Serial Communication: RS-232 (IEEE Standard)
E3165 DIGITAL ELECTRONIC SYSTEM
UART Serial Port Programming
Serial Communication Interface: Using 8251
Serial Communication Interface
UART PC16550 (Universal Asynchronous Receiver/Transmitter) By Derwyn Hollobaugh
CHAPTER SERIAL PORT PROGRAMMING. Basics of Serial Communication Computers transfer data in two ways: ◦ Parallel  Often 8 or more lines (wire.
Presentation transcript:

1 מעבדה במבוא לתקשורת מועבר ע ” י דני סיטרון כל החומר על הקורס ( החומר שיילמד, תרגילים, ציונים, שעות קבלה …) נמצא ב : בהתאם לאמונה שלי שתלמיד שאינו שולט באנגלית לא יכול להתהדר בתואר אקדמי במדעי המחשב, אזי : זה השקף האחרון בעברית שתראו בקורס

2 RS-232C Standard The RS-232C standard is an asynchronous serial communication method. Serial means that the information is sent 1-bit at a time. Asynchronous means that the information isn't sent at predefined time slots (like with a fixed clock, for instance). The RS-232C standard works at the physical layer of the communication standard. This is the lowest level and the one that physically connects the devices. The communication is done through the serial port of the PC. This is a male connector with 25 (old) or 9 (new) pins, in both cases only 9 pins, at the most, are used.

3 Why Use a Serial Interface? Good question? We program in parallel (writing a value to a char, int, float), why communicate serially? Less data is transferred per send. There are several reasons: –Serial cables can be longer than parallel cables. –Serial cables are cheaper than parallel cables, although there is a cost of converting parallel data to the serial connection. –Infra Red devices are becoming popular. Detecting 1 point of light isn't easy, try detecting 8 or more points of light. –Many microcontrollers ( מיקרו - מעבדים ) use SCI (Serial Communication Interface) to communicate with the outer world.

4 The Connector The pins abbreviations are (numbers in parentheses are the 25D pin numbers. 1. CD (8) 2. RD (Rx) (3) 3. TD (Tx) (2) 4. DTR (20) 5. SG (Ground) (7) 6. DSR (6) 7. RTS (4) 8. CTS (5) 9. RI (22)

5 9D to 25D Conversion

6 DTE and DCE A DTE (Data Terminal Device) is usually a computer. A DCE (Data Communication Device) is usually a Modem. A Cable connecting 2 PCs is also a Modem. It is called a NULL Modem. The problem with communications is that the DTE speed is much greater than the DCE speed. The communication protocol bridges this gap ( מגשר על הפער ). The DCE to DCE speed is also called the line speed. Maximum Modem speed today is 56K BPS (56K Bits Per Second), this is the line speed. On the other hand the maximum DTE/DCE speed is 115,200 BPS. This is the gap software must bridge.

7 The UART 8250 OK, lets say we understood the previous slides. How does the CPU send signals through the serial port? A UART (Universal Asynchronous Receiver/Transmitter) is used. The UART is a device that the CPU programs to perform tasks for it. In our case the UART 8250 is the device that controls the serial port. The 8250 is the first of a family that contains the 8250B, 16450, and others. The 8250 was introduced with the XT PC, so your computer probably has a later version. But all are backward compatible, so we can program as though we have a 8250.

8 Programming the UART 8250 Programming is done by reading and writing registers of the The registers are: Base Address Mode Name +0 (DLAB=0)WriteTransmitter Holding Buffer THR +0 (DLAB=0)ReadReceiver Buffer RBR +0 (DLAB=1)Rd/WrDivisor Latch Low Byte DLL +1 (DLAB=0)Rd/WrInterrupt Enable Register IER +1 (DLAB=1)Rd/WrDivisor Latch High ByteDLM +2ReadInterrupt Idendification Register IIR +2WriteFIFO Control RegisterFCR +3Rd/WrLine Control Register LCR +4Rd/WrModem Control RegisterMCR +5ReadLine Status Register LSR +6ReadModem Status Register MSR +7Rd/WrScratch RegisterSCR

9 Accessing the Registers On the 80x86 architecture I/O devices are accessed using special I/O instructions. These instructions called IN and OUT, access I/O Ports. I/O Ports are addresses in what's called I/O space, these are addresses that when accessed using the special I/O instructions access the registers of I/O devices. The PC has standard ports for the serial interfaces, these ports are called COM1 - COM4. They are mapped to the following port numbers and IRQ (Interrupt Request) lines. Name Port address IRQ COM 13F84 COM 22F83 (usually the serial mouse) COM 33E84 COM 42F83

10 Getting the Port Addresses #include void main(void) { unsigned int far *ptraddr; /* Pointer to location of Port Addresses */ unsigned int address,a; /* Address of Port */ ptraddr=(unsigned int far *)0x ; for (a = 0; a < 4; a++) { address = *ptraddr; if (address == 0) printf("No port found for COM%d \n",a+1); else printf("Address assigned to COM%d is %Xh\n",a+1,address); *ptraddr++; }}

11 Accessing the Registers The port addresses for the COMs are defined in the BIOS (Basic I/O System) ROM (Read Only Memory) from addresses 0x400 to 0x408. OK. So how do we access the registers? There is a C interface to the IN and OUT instructions: int inp(unsigned short port); // read a byte from the port int outp(unsigned short port, int val); // write a byte to the port Using these two instruction is is possible to access the registers defined in the previous slides. For instance to read the LCR we have to write: int val; val = inp(0x3F8 + 3); // or inp(0x3FB); Look at the functions descriptions in the help manuals of Visual C++ or BorlandC.

12 Real vs. Protected Mode Protected mode is the mode that the computer runs in when it has to support multiple users. UNIX and NT run only in protected mode. A regular user can’t access the I/O ports. Real mode (or single-user mode, or priveleged-mode) is the mode used by the OS to access I/O devices. DOS runs in real mode. W95/98 is a hybrid ( בן - כלאיים ) between real and protected mode. We will use DOS in order to run are programs, but try W95 to see if you can access the I/O ports. inp and outp work when compiled with BorlandC, the Visual C++ versions ( _inp and _outp ) might create problems, try it out.

13 Baud Rate The rate of transfer is in BPS. The UART 8250 has a clock that's rate is MHz. The UART divides the clock signal by 16, giving a maximum baud of 115,200 BPS. But this rate might be to fast for some devices, so the rate is controllable. Lets say we want to communicate at 2400 BPS. We have to divide the clock rate by a number multiplied by 16 to get the desired rate. This number is called the baud rate. Thus in our case 2400 = *10 6 /(baud rate * 16). The baud rate = *10 6 /(2400 * 16) = 48 The baud rate is stored in the DLL and DLM before transmission starts. The DLL Contains the 8 LSBs (Least Significant Bits) and the DLM contains the 8 MSBs (Most Significant Bits).

14 RS-232C Waves So far we have introduced RS-232 Communications in relation to the PC. RS-232 communication is asynchronous. That is a clock signal is not sent with the data. Each word is synchronized using it's start bit, and an internal clock on each side (defined by the baud rate) reads the data. The signal is in the logical 1 state (also called "mark"), a start bit which is in logical state 0 (also called "space") signals that data is about to be sent. Then 8 bits of data are sent (this can be changed), a parity bit is optional (not shown here) and the a stop bit (or bits) is sent. This is called a frame ( מסגרת ). The data is framed between a stop and start bit. The above waveform is relevant to the TD and RD lines only.

15 The Line Control Register (LCR) The LCR is a 8-bit register (as all 8250 registers) that controls the data that goes on the TD and RD lines. Its bits are: Bits 0,1: Select the word length, from 5 to 8 bits. –00: 5 bit word –01: 6 bit word –10: 7 bit word –11: 8 bit word Bit 2: Sets the length of the stop bit. –0: 1 bit length –1: 1.5 bit length if 5 bit word selected, 2 bit length if 6,7,8 bit word selected Bit 6: Sets the break control bit. When this bit is set to 1 the TD line is permanently set to 0 (space). Bit 7: Sets the DLAB (Divisor Latch Access Bit). –0: enables access to RBR, THR, and IER. –1: enables access to DLL and DLM (to set the baud).

16 The LCR Parity Bits Bit 3: Parity enable bit. –0: no parity bit sent –1: parity bit sent Bit 4: Chooses between odd and even parity. –0: odd parity. The number of '1's in the word is counted. If odd the parity bit is set, if even it isn't set. –1: even parity. The number of '1's in the word is counted. If even the parity bit is set, if odd it isn't set. –For instance the word has odd parity. So if parity is enabled (bit 3) and bit 4 is 0 (odd parity), the parity bit sent will be 1 and the receiver will check the data and expect to find a 1 in the parity bit. Bit 5: Sets the "sticky" parity bit. The parity bit is always the same value, "high" (1) or "low" (0). –0: The parity bit is set by the input word. –1: The parity bit is 0 is bit 4 is 1, the parity bit is 1 if bit 4 is 0. This setting is permanent as long as bit 6 is set.

17 Sending a Word In order to send a word the following steps must be taken on both sides (sender and receiver). Set the baud rate by computing it and loading DLL and DLM. Set the parity (enabled on/off, odd/even). Set the word length (5-8 bits). Set the number of stop bits. Write a word to the THR. This word (lets assume 8-bit words) is written into the TSR (Transmit Shift Register). The TSR then shifts the bits out one by one and transmits them on the TD line. The word is received by the RD on the receivers side and stored in the RBR register. THR TSRTD

18 The Line Status Register (LSR) The LSR shows the current status of communication, errors in transmission will be written into the register. Bit 0: Data Ready (DR) indicator. When set it indicates that a byte is ready to be read from the RBR. Reading from the RBR sets the DR bit to 0. Bit 1: Overrun Error (OE) indicator. When set indicates that a new byte has been received before the current byte in the RBR has been read. The OE is reset (set to 0) when the LSR is read. Bit 2: Parity Error (PE) indicator. When set indicates that a parity error has occurred. Is reset by reading the LSR. Bit 3: Framing Error (FE) indicator. Is set whenever the received word doesn't have a valid stop bit. The stop bit following the last data bit or parity is detected as a 0 instead of a 1. Bit 4: Break Interrupt (BI) indicator. Is set whenever the RD line is held in the space state for longer than it takes to send a word.

19 The LSR (cont.) Bit 5: Transmitter Holding Register Empty (THRE) indicator. When set it is possible to write another byte into the THR. The bit is set when the byte is transferred from the THR to the TSR. The bit is reset when the processor starts loading a byte into the THR. Bit 6: Transmitter Shift Register Empty (THRE) indicator. When set indicates that the TSR is empty. It is reset when a word is loaded into it from the THR. Bit 7: Unused. Permanent 0.