ECE291 Computer Engineering II Lecture 12 Josh Potts University of Illinois at Urbana- Champaign.

Slides:



Advertisements
Similar presentations
MICROPROCESSOR BASED SYSTEM DESIGN
Advertisements

Accessing I/O Devices Processor Memory BUS I/O Device 1 I/O Device 2.
INPUT-OUTPUT ORGANIZATION
Dr A Sahu Dept of Computer Science & Engineering IIT Guwahati.
MICROPROCESSORS TWO TYPES OF MODELS ARE USED :  PROGRAMMER’S MODEL :- THIS MODEL SHOWS FEATURES, SUCH AS INTERNAL REGISTERS, ADDRESS,DATA & CONTROL BUSES.
Programmable Interval Timer
8253/54 Timer Section /54 Timer Description and Initialization
Real-Mode Interrupts Chapter 15 S. Dandamudi To be used with S. Dandamudi, “Introduction to Assembly Language Programming,” Second Edition, Springer,
CS-334: Computer Architecture
Set 20 Interrupts. INTERRUPTS The Pentium has a mechanism whereby external devices can interrupt it. Devices such as the keyboard, the monitor, hard disks.
P Address bus Data bus Read-Only Memory (ROM) Read-Write Memory (RAM)
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.
Group 7 Jhonathan Briceño Reginal Etienne Christian Kruger Felix Martinez Dane Minott Immer S Rivera Ander Sahonero.
University of Tehran 1 Interface Design Keyboard and Printer Omid Fatemi.
INPUT-OUTPUT ORGANIZATION
Khaled A. Al-Utaibi  Intel Peripheral Controller Chips  Basic Description of the 8255  Pin Configuration of the 8255  Block Diagram.
Interrupts. What Are Interrupts? Interrupts alter a program’s flow of control  Behavior is similar to a procedure call »Some significant differences.
Lecture 9. - Synchronous Devices require a timing signal. Clock generated Interval Timer Microprocessor Interval Timer Clk PCLK = MHz PCLK (for.
ENEE 440 Chapter Timer 8254 Register Select The 8254 timer is actually 3 timers in one. It is an upgraded version of the 8253 timer which was.
8253 TIMER. Engr 4862 Microprocessors 8253 / 8254 Timer A.k.a. PIT (programmable Interval Timer), used to bring down the frequency to the desired level.
PIT: Programmable Interval Timer
CPU Interfacing Memory.
Dr. Rabie A. Ramadan Al-Azhar University Lecture 6
ECE291 Computer Engineering II Lecture 9 Josh Potts University of Illinois at Urbana- Champaign.
The 8253 Programmable Interval Timer
MICROPROCESSOR INPUT/OUTPUT
Input/Output Interface Circuits and LSI Peripheral Devices
Basic Architecture Lecture 15. In general, if the number of bits is n, then the number of different combinations of 0s and 1s that can be made is 2 n.
PIT Programming Examples Working with the modes of PIT.
ECE291 Lecture 8 Peripheral devices. ECE 291 Lecture 8Page 2 of 37 Lecture outline Hardware I/O with ports 8253 timer PC speaker Serial port Parallel.
Advanced Microprocessor1 I/O Interface Programmable Interval Timer: 8254 Three independent 16-bit programmable counters (timers). Each capable in counting.
8279 KEYBOARD AND DISPLAY INTERFACING
Practical Session 11 Computer Architecture and Assembly Language Input &Output (I/O)
Lecture 12 Peripherals Dr. Dimitrios S. Nikolopoulos CSL/UIUC.
Accessing I/O Devices Processor Memory BUS I/O Device 1 I/O Device 2.
CSNB374: Microprocessor Systems Chapter 5: Procedures and Interrupts.
8086 Microprocessor Interrupts By: Vijay Kumar. K Reference From Slide Share.
Computer Hardware A computer is made of internal components Central Processor Unit Internal External and external components.
SET 21 OPERATING SYSTEM USE OF ASSEMBLY LANGUAGE.
8254 Timer.
PPI-8255.
8279 KEYBOARD AND DISPLAY INTERFACING
Programmable Interrupt Controller (PIC)
Basic I/O Interface Fixed Address Variable Address
Basic LED Interface.
Khaled A. Al-Utaibi  I/O Ports  I/O Space VS Memory Space  80x86 I/O Instructions − Direct I/O Instructions − Indirect I/O Instructions.
1 Microprocessors CSE – 341 Basic I/O Interfacing.
I/O Interface. INTRO TO I/O INTERFACE I/O instructions (IN, INS, OUT, and OUTS) are explained. Also isolated (direct or I/O mapped I/O) and memory-mapped.
ECE291 Computer Engineering II Lecture 16 Josh Potts University of Illinois at Urbana- Champaign.
بسم الله الرحمن الرحيم MEMORY AND I/O.
KEYBOARD/DISPLAY CONTROLLER - INTEL Features of 8279 The important features of 8279 are, Simultaneous keyboard and display operations. Scanned keyboard.
Practical Session 11 Computer Architecture and Assembly Language Input &Output (I/O)
An Interrupt is either a Hardware generated CALL (externally derived from a hardware signal) OR A Software-generated CALL (internally derived from.
Homework Reading Machine Projects Labs
8254 – SOFTWARE PROGRAMMABLE TIMER
Computer Organization & Assembly Language Chapter 3
Programmable Interval Timer
Symbolic Instruction and Addressing
Interfacing Memory Interfacing.
Programmable Interval timer 8253 / 8254
Morgan Kaufmann Publishers Computer Organization and Assembly Language
Symbolic Instruction and Addressing
Programmable Peripheral Interface
COMPUTER PERIPHERALS AND INTERFACES
Programmable Interval timer 8253 / 8254
Symbolic Instruction and Addressing
Computer Architecture and Assembly Language
8253 – PROGRAMMABLE INTERVAL TIMER (PIT). What is a Timer? Timer is a specialized type of device that is used to measure timing intervals. Timers can.
Chapter 6 –Symbolic Instruction and Addressing
Presentation transcript:

ECE291 Computer Engineering II Lecture 12 Josh Potts University of Illinois at Urbana- Champaign

Thursday, June 02, 2016ECE291 – Lecture 12Slide 2 of 21 Outline Hardware I/O with ports 8253 Timer PC Speaker Parallel Port

Thursday, June 02, 2016ECE291 – Lecture 12Slide 3 of 21 IN/OUT Instructions Use to perform I/O operations IN instruction transfers data from an external I/O device to AL, AX, or EAX OUT instruction transfers data from AL, AX, or EAX to an external I/O device

Thursday, June 02, 2016ECE291 – Lecture 12Slide 4 of 21 IN/OUT Instructions Two forms of I/O device (port) addressing –Fixed-port addressing allows data transfer using an 8-bit I/O port address (use if port is 0 – 255) –port number is immediate (follows the instruction opcode) IN AL, 6Ah;data from I/O address 6Ah is input to AL –Variable-port addressing allows data transfer using 16-bit port address (addresses above 255) –the I/O port number is usually stored in register DX, which can be changed during the execution of the program MOV DX, FA64h OUT DX, AX ;transfers the contents of AX to I/O port FA64h

Thursday, June 02, 2016ECE291 – Lecture 12Slide 5 of 21 IN/OUT Instructions (simple example)..START INal, 61h;read port 61h ORal, 3;set bits 0 and 1 OUT61h, al;turn speaker on MOVcx, 1000h;delay count; if the count is increased, ;the click will become longer.L1LOOP.L1 ;time delay – spin 1000h times INal, 61h ANDal, 0fch;clear bits 0 and 1 OUT61h, AL;turn speaker off MOV ax, 4c00h;Normal DOS Exit INT 21h

Thursday, June 02, 2016ECE291 – Lecture 12Slide 6 of 21 Peripheral Control Keyboard The keyboard is controlled by a microcontroller that contains a simple microprocessor The keyboard is connected to the 8255 PPI chip (Programmable Peripheral Interface) –The PPI contains three registers A, B, and C which are accessed on ports 60h-62h using the in/out instructions When a key is pressed or released two events take place: –an 8-bit scan code is deposited in register A of the PPI –an INT 09h hardware interrupt is generated on IRQ1 of the 8259 PIC Default ISR gets the scan code, sends the ACK to the PIC passes information to the keyboard buffer (a storage area in the BIOS data area)

Thursday, June 02, 2016ECE291 – Lecture 12Slide 7 of 21 Peripheral Control Keyboard Each key press is stored in the buffer as a word –normal characters are stored with ASCII code for the character, and the scan code for the key –extended codes corresponding to special keys e.g., cursor keys, shift The keyboard buffer is a circular buffer, when it gets full and a new key is pressed: –INT 09 generates a “bell” character, which causes the speaker to beep –The data from the new key press is discarded Keyboard buffer holds keystrokes until read by an INT 16

Thursday, June 02, 2016ECE291 – Lecture 12Slide 8 of 21 Peripheral Control 8253 Programmable Interval Timer Intel 8253 contains 3 independent 16-bit programmable counters (timers) Operate under the main timing pulse of MHz This frequency is divided by 12 before being sent to the timer so the basic pulses arrive at frequency MHz Timer 0 –Connected to IRQ0 line of the 8259 PIC (interrupt 08) –Counts down from to zero –The output signal occurs each ( * 10 6 )/ = 18.2 Hz Timer 1 –Causes the DRAM memory system to be refreshed Timer 2 –Connected to a speaker

Thursday, June 02, 2016ECE291 – Lecture 12Slide 9 of 21 Peripheral Control 8253 Programmable Interval Timer 8253 is mapped to I/O ports 40h-43h PortDescription 40h Timer 0 Count Register 41h Timer 1 Count Register 42h Timer 2 Count Register 43h Timer Control Register

Thursday, June 02, 2016ECE291 – Lecture 12Slide 10 of 21 Peripheral Control 8253 Programmable Interval Timer The Control Register allows the programmer to select the counter, mode of operation, and type of operation (read/write) Bits Description 7,6 Counter ID (00,01,10) 00: latch count for reading 5,401: Read/Set least significant byte 10: Read/Set most significant byte 11: Read/Set least significant byte then most significant byte 3,2,1 Count Mode (011=Square Wave) 0 Count Method: 0=Binary, 1=BCD

Thursday, June 02, 2016ECE291 – Lecture 12Slide 11 of 21 Peripheral Control Speaker Control Timer 2 Output from 8253 Enable timer input to speaker (port 61h, bit 1) Enable speaker (port 61h, bit 0) Write to Control Port moval, b out43h, al 10:Control timer 2 11:Load Low Byte then High Byte 011:Select Square wave output 0:Count in binary

Thursday, June 02, 2016ECE291 – Lecture 12Slide 12 of 21 Peripheral Control Speaker Control Enable Speaker INal, 61h ORal, b OUT61h, al Bit 1: Enable Timer Bit 0: Enable Speaker Don't change other bits Write Count to timer OUT 42h, al MOV al, ah OUT 42h, al AX=count (ticks) = (ticks/sec) / Freq (1/sec)

Thursday, June 02, 2016ECE291 – Lecture 12Slide 13 of 21 Simple Tones Produced Using Square Wave CR EQU 13 LF EQU 10 extrn dosxit, kbdin, dspmsg, binasc ; Define stack segment stkseg SEGMENT stack ; *** STACK SEGMENT RESB 512 stktop ; Define code segment cseg SEGMENT CODE ; Main procedure pbuf RESB 7 crlf db CR,LF,'$' freq_msg db ' Freq = $' count_msg db ' Hz, Count = $'

Thursday, June 02, 2016ECE291 – Lecture 12Slide 14 of 21 Simple Tones Produced Using Square Wave..start main mov ax, cs ; Initialize DS register mov ds, ax mov al, b ; Timer2, Load L+H, square wave, ; binary out 43h,al ; Write timer control byte in al,61h or al, b ; Enable Timer2 & Turn on speaker out 61h,al.mloop call kbdin cmp al,'0' ; 0 to quit je.mdone sub al,'0' mov ah,0

Thursday, June 02, 2016ECE291 – Lecture 12Slide 15 of 21 Simple Tones Produced Using Square Wave mov cl,8 ; Freq * 256 (Hz) shl ax,cl mov dx, freq_msg call dspmsg mov bx, pbuf call binasc mov dx, pbuf call dspmsg ; Print Freq mov bx,ax mov ax,34DCh ;DX:AX=1,193,180 (tics/sec) mov dx,12h ;AX = div bx ;BX=Freq (1/sec) mov dx, count_msg call dspmsg mov bx, pbuf call binasc

Thursday, June 02, 2016ECE291 – Lecture 12Slide 16 of 21 Simple Tones Produced Using Square Wave mov dx, pbuf call dspmsg ; Print count mov dx, crlf call dspmsg out 42h,al ; Write Low byte to Timer Channel 2 mov al,ah out 42h,al ; Write High byte to Timer Channel 2 jmp.mloop.mdone in al,61h and al, b ; Turn off speaker out 61h,al call dosxit ; Exit to DOSmain

Thursday, June 02, 2016ECE291 – Lecture 12Slide 17 of 21 Peripheral Control Parallel Interface Originally designed for use with printers only Provides 8-bit I/O Provides TTL-level (5V) external I/O When the computer boots it detects any parallel ports and assigns ‘logical’ port names to them (LPT1, LPT2, LPT3) Each printer adapter uses three processor I/O ports –data output (to send a byte of data to a printer you send the data to the output data register) –status signals from the printer –control/commands to the printer

Thursday, June 02, 2016ECE291 – Lecture 12Slide 18 of 21 Peripheral Control Parallel Interface Each logical device has a unique Port I/O address Device Data Port Status Port Control Port LPT0: 3BCh 3BDh 3BEh LPT1: 378h 379h 37Ah LPT2: 278h 279h 27Ah The printer base addresses are stored at 40:0008h, and can be accessed by using the DEBUG program –At the command prompt, type “debug” to get the “-” debug prompt –type d40:0008 (and hit return) –you get : 0040:0008BC ….. –the first six bytes are addresses of the installed printer adapters

Thursday, June 02, 2016ECE291 – Lecture 12Slide 19 of 21 Peripheral Control Parallel Interface - Major Signals Signal(s)Input/OutputNotes Data[7:0]Bi-directionalByte-wide data bus StrobeTo deviceWrite signal BusyFrom deviceDon't send more data AckFrom deviceAcknowledge (interrupt signal) InitializeTo deviceInitialize external device Out of PaperFrom deviceStatus signal

Thursday, June 02, 2016ECE291 – Lecture 12Slide 20 of 21 Peripheral Control Writing to the Parallel Interface

Thursday, June 02, 2016ECE291 – Lecture 12Slide 21 of 21 Control & Status Ports Control Port Bit Description 7-5 Unused 4 IRQ Enable 3 Select [inverted] 2 Initialize 1 AutoFeed [inverted] 0 Strobe [inverted] Status Port Bit Description 7 Busy [inverted] 6 Ack 5 Out-of-Paper 4 Selected 3 I/O Error 2-0 Unused