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.

Slides:



Advertisements
Similar presentations
Jim Chen ( 14/06/2011 Hytec Electronics Ltd.
Advertisements

IO Interfaces and Bus Standards. Interface circuits Consists of the cktry required to connect an i/o device to a computer. On one side we have data bus.
Computer Architecture
Accessing I/O Devices Processor Memory BUS I/O Device 1 I/O Device 2.
11-1 ECE 424 Design of Microprocessor-Based Systems Haibo Wang ECE Department Southern Illinois University Carbondale, IL I/O System Design.
Chapter 10 Input/Output Organization. Connections between a CPU and an I/O device Types of bus (Figure 10.1) –Address bus –Data bus –Control bus.
SCI: Serial Communications Interface Presented by: Sean Kline Chad Smith Jamie Cruce.
1 Homework Reading –Tokheim, Section 13-6 Continue mp1 –Questions? Labs –Continue labs with your assigned section.
Serial I/O - Programmable Communication Interface
Hierarchy of I/O Control Devices
1 Homework Reading –Review previous material on “interrupts” Machine Projects –MP4 Due today –Starting on MP5 (Due at start of Class 28) Labs –Continue.
Asynchronous Communication Hardware  Data within a DTE is usually stored and moved in a parallel fashion.  Data sent across the channel is generally.
Communication Lab - Interrupts 1/13 Sequential Programming  Our C++ programs are sequential ( סדרתיים), they start at the first instruction and end at.
1 Homework Reading –Professional Assembly Language, pp 17-32, Continue work on mp1 –Questions? Lab with your assigned section this week.
7-1 Digital Serial Input/Output Two basic approaches  Synchronous shared common clock signal all devices synchronised with the shared clock signal data.
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)
Practical Session No. 10 Input &Output (I/O). I/O Devices Input/output (I/O) devices provide the means to interact with the “outside world”. An I/O device.
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
ECE 265 – LECTURE 12 The Hardware Interface 8/22/ ECE265.
Input/Output. Input/Output Problems Wide variety of peripherals —Delivering different amounts of data —At different speeds —In different formats All slower.
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),
Chapter 10: Input / Output Devices Dr Mohamed Menacer Taibah University
UART and UART Driver B. Ramamurthy.
Introduction to Embedded Systems Buffering and DMA (Direct Memory Access) Lecture 11.
Universal Synchronous/Asynchronous Receiver/Transmitter (USART)
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Principles of I/0 hardware.
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
 8251A is a USART (Universal Synchronous Asynchronous Receiver Transmitter) for serial data communication.  Programmable peripheral designed for synchronous.
Practical Session 11 Computer Architecture and Assembly Language Input &Output (I/O)
Universal Asynchronous Receiver/Transmitter (UART)
Accessing I/O Devices Processor Memory BUS I/O Device 1 I/O Device 2.
Programming the I/O Hardware Reference: –textbook: Tanenbaum ch.5.1 – s.htmlwww.cs.umb.edu/ulab/UsingCforHardwareReg.
CH10 Input/Output DDDData Transfer EEEExternal Devices IIII/O Modules PPPProgrammed I/O IIIInterrupt-Driven I/O DDDDirect Memory.
بسم الله الرحمن الرحيم MEMORY AND I/O.
8251 USART.
80C51 Block Diagram 1. 80C51 Memory Memory The data width is 8 bits Registers are 8 bits Addresses are 8 bits – i.e. addresses for only 256.
Transmitter Interrupts Review of Receiver Interrupts How to Handle Transmitter Interrupts? Critical Regions Text: Tanenbaum
DEPARTMENT OF ELECTRONICS ENGINEERING V-SEMESTER MICROPROCESSOR & MICROCONTROLLER 1 CHAPTER NO microcontroller & programming.
Practical Session 11 Computer Architecture and Assembly Language Input &Output (I/O)
Lecture 15. Modem Controller Register 4310 DTR 0 = Polling Operator 1 = Interrupts Enabled RTS 1 =Self Test 0 =Normal.
Lecture # 14. RS – 232C Standard Standard for physical dimensions of the connectors. PC (DTE) Modem RS – 232C Cable Connected via serial port (DCE)
Homework Reading Machine Projects
Types of format of data transfer
Homework Reading Machine Projects Labs
Serial mode of data transfer
Homework Reading Labs Tokheim, Section 13-6 S and S Extracts
Homework Reading Continue mp1 Labs Tokheim, Section 13-6 Questions?
CS-401 Computer Architecture & Assembly Language Programming
Programming the I/O Hardware
Homework Reading (linked from my web page) Machine Projects Labs
Serial I/O and Data Communication.
SERIAL PORT PROGRAMMING
CS 286 Computer Organization and Architecture
Homework Reading Machine Projects Labs
Serial Communication: RS-232 (IEEE Standard)
Homework Reading Continue work on mp1
UART Serial Port Programming
Programming the I/O Hardware
Serial Communication Interface: Using 8251
Serial Communication Interface
UART Protocol Chapter 11 Sepehr Naimi
Transmitter Interrupts
Computer Architecture and Assembly Language
CHAPTER SERIAL PORT PROGRAMMING. Basics of Serial Communication Computers transfer data in two ways: ◦ Parallel  Often 8 or more lines (wire.
8051SERIAL PORT PROGRAMMING
Chapter 13: I/O Systems “The two main jobs of a computer are I/O and [CPU] processing. In many cases, the main job is I/O, and the [CPU] processing is.
Presentation transcript:

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 –Continue labs in your assigned section

2 Addressing I/O Devices Intel I/O devices have addresses assigned in an “orthogonal” space from memory addresses –Remember the M/IO# signal that is used with the address bus to select memory versus I/O devices? Use I/O instructions for I/O device addresses inwinb outwoutb

3 Addressing I/O Devices The “input” instruction – direct addressing inw $0xdd, %ax # 8 bit address inb $0xdd, %al # 8 bit address The “input” instruction – indirect addressing movw $0x3f8, %dx inw (%dx), %ax # 16 bit address inb (%dx), %al # 16 bit address Reads from an I/O device to a register

4 Addressing I/O Devices The “output” instruction – direct addressing outw %ax, $0xdd # 8 bit address outb %al, $0xdd # 8 bit address The “output” instruction – indirect addressing movw $0x3f8, %dx outw %ax, (%dx) # 16 bit address outb %al, (%dx) # 16 bit address Writes from a register to an I/O device

5 Addressing I/O Devices In some processor architectures (Motorola), there is no M/IO# signal in the control bus This is called using “memory mapped I/O” –I/O device addresses are in the same address space as memory –I/O device ports are accessed as memory addresses –Use equivalent of “move” instructions to write or read data to or from I/O device registers as memory

6 Addressing I/O Devices COM port addresses (Neveln, Table 4.2) * corrects an error in the text COM Port I/O Addresses x3F8-0x3FF 0x2F8-0x2FF 0x3E8-0x3EF 0x2E8-0x2EF *

7 Accessing the Serial Port PC specification allows up to four serial ports –COM1: base address is 0x3f8 –COM2: base address is 0x2f8 0x3f8 0x3fc 0x3fb WriteRead D7D6D5D4D3D2D1D0D7D6D5D4D3D2D1D0 DLAB Set Brk Evn Par Enb # Stop LoopOut2Out1RTSDTR Len Sel 1 Len Sel 0 0x3fd 0x3fe Same as Write Stk Par DCD RIDSRCTS DCD CHG DSR CHG CTS CHG TE RI RX ERR TX EMP THREBRK Int FRM ERR PAR ERR OVRN ERR Data RDY 0

8 Accessing the Serial Port Don’t want to use hard coded numbers! Look at $pcinc/serial.h for symbolic constants #define COM1_BASE 0x3f8 #define COM2_BASE 0x2f8 #define UART_TX 0 /* send data */ #define UART_RX 0 /* recv data */... #define UART_LCR 3 /* line control */ #define UART_MCR 4 /* modem control */ #define UART_LSR 5 /* line status */ #define UART_MSR 6 /* modem status */

9 Parallel Serial Conversion UART performs double buffered, bidirectional, parallel-to-serial / serial-to-parallel conversion: Transmit Holding Register Transmit Shift Register TXD (Serial) THRE TX Empty Data Bus (Parallel) RXD (Serial) Data ReadyReceive Shift Register Receive Holding Register Overrun Error

10 Strategies for I/O Driver Code Two Basic Strategies for I/O Driver Code –Status Polling –Interrupt Driven Status Polling –Uses only the port addresses on the I/O device –Ties up the entire processor for the duration of I/O Interrupt Driven –Adds an interrupt line from I/O device to processor –Allows processor to do other work during I/O

11 Status Polling Review the serial port details: –Status and Control Registers We will look at assembly language driver to send and receive data in “full duplex” mode –Half Duplex – Sending or receiving alternately (data going only one direction at a time) –Full Duplex – Sending and receiving at same time (data going both directions simultaneously)

12 Initializing the UART Tutor does this for us on COM1: and COM2: –Select speed, data bits, parity, and number of stop bits –Turn on DTR and wait for DSR on Half duplex mode modem signal handshake: –Transmit: Turn on RTS and wait for CTS on –Receive: Turn off RTS and wait for DCD on Full duplex mode modem signal handshake: –Turn on RTS and leave it on –Transmit whenever CTS on –Receive whenever DCD on

13 Status Polling Loop on send/receive data to/from COM2: (Assume Tutor has initialized bit rate and line control) 1. Turn on DTR & RTS, wait for DSR, CTS, & DCD 2. Read data ready (DR) 3. If data is ready, read a byte of receive data 4. Read transmit holding register empty (THRE) 5. If THR is empty, write a byte of transmit data 6. Jump back to step 2 Processor loop is much faster than byte transfer rate But, hard to do other work while looping on status

14 Status Polling Assembly Code Step 1a: Turn on DTR and RTS movw $0x2fc, %dx# modem control inb (%dx), %al# get current orb $0x03, %al# or on 2 lsbs outb %al, (%dx)# set control

15 Status Polling Assembly Code Step 1b: Wait for DSR, CTS, and DCD movw $0x2fe, %dx# modem status loop1: inb (%dx), %al# get current andb $0xb0, %al# get 3 signals xorb $0xb0, %al# check all 3 jnz loop1# some missing # all 3 are on now

16 Status Polling Assembly Code Step 2: Read Data Ready Step 3: If ready, read a byte from receive data loop2: movw $0x2fd, %dx# line status inb (%dx), %al# get data ready andb $0x01, %al# look at dr jz xmit# if recv data movw $0x2f8, %dx# i/o data addr inb (%dx), %al# move rx to %al movb %al, somewhere# save it somewhere movw $0x2fd, %dx# line status

17 Status Polling Assembly Code Step 4: Read transmit holding register empty Step 5: If empty, write a byte to transmit data xmit: inb (%dx), %al# get thre andb $0x20, %al# look at thre jz loop2# if tx hr empty movb somewhere, %al# get data to send movw $0x2f8, %dx# i/o data addr outb %al, (%dx)# send it jmp loop2# and loop

18 COM Port Driver in C - Receive #include void unsigned char pollgetc() { /* polling loop, waiting for DR bit to go on */ while ((inpt(COM1_BASE + UART_LSR) & UART_LSR_DR) == 0) ; /* input character */ return inpt(COM1_BASE + UART_RX); }

19 COM Port Driver in C - Transmit #include void pollputc(unsigned char ch) { /* polling loop, waiting for THRE bit to go on */ while ((inpt(COM1_BASE + UART_LSR) & UART_LSR_THRE) == 0) ; /* output character */ outpt(COM1_BASE + UART_TX, ch); }