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

Slides:



Advertisements
Similar presentations
Accessing I/O Devices Processor Memory BUS I/O Device 1 I/O Device 2.
Advertisements

INPUT-OUTPUT ORGANIZATION
Dr. Rabie A. Ramadan Al-Azhar University Lecture 3
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
82C55 82C55 Programmable Peripheral Interface Interfacing Part III.
Microprocessor and Microcontroller
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.
INPUT-OUTPUT ORGANIZATION
Khaled A. Al-Utaibi  Intel Peripheral Controller Chips  Basic Description of the 8255  Pin Configuration of the 8255  Block Diagram.
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
Dr. Rabie A. Ramadan Al-Azhar University Lecture 6
The 8253 Programmable Interval Timer
MICROPROCESSOR INPUT/OUTPUT
By, Prof. Tambe S. S. S.N.D. College of Engineering and Research Center Department of Electrical Engineering.
Input/Output Interface Circuits and LSI Peripheral Devices
BIOS and DOS Programming in DOS INT 10 and 21H. Interrupts There are some extremely useful subroutines within BIOS or DOS that are available to the user.
1 Microprocessor-based Systems Course 8 Design of input/output interfaces.
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
ECE291 Computer Engineering II Lecture 12 Josh Potts University of Illinois at Urbana- Champaign.
Lecture 12 Peripherals Dr. Dimitrios S. Nikolopoulos CSL/UIUC.
Accessing I/O Devices Processor Memory BUS I/O Device 1 I/O Device 2.
ECE291 Computer Engineering II Lecture 3 Josh Potts University of Illinois at Urbana- Champaign.
CSNB374: Microprocessor Systems Chapter 5: Procedures and Interrupts.
University of Tehran 1 Microprocessor System Design Timers Omid Fatemi
8086 Microprocessor Interrupts By: Vijay Kumar. K Reference From Slide Share.
8085. Microcomputer Major components of the computer - the processor, the control unit, one or more memory ICs, one or more I/O ICs, and the clock Major.
EENG4005 Outline Program organization Debugging hints MASM directives.
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.
EE3721 Computer System Principles
8279 KEYBOARD AND DISPLAY INTERFACING
A Design Example A Programmable Calculator. Programmable Calculator Working in Exact Mode Receiving Program from RS232 Port Saving Programs using RS232.
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.
Review Yuanqing Cheng. Outline Part I: Introduction of X86 based computing system Part II: Assembly programing Part III: Interfacing circuit design.
1 Microprocessors CSE – 341 Basic I/O Interfacing.
1 Basic Processor Architecture. 2 Building Blocks of Processor Systems CPU.
8086 – I/O Interfacing - I/O mapped I/O
File Operations. FILE PROCESSING For the purposes of the following discussion, reading means copying all or part of an existing file into memory Writing.
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.
Format of Assembly language
COURSE OUTCOMES OF Microprocessor and programming
Homework Reading Machine Projects Labs
8254 – SOFTWARE PROGRAMMABLE TIMER
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 Interval timer 8253 / 8254
Symbolic Instruction and Addressing
Computer Architecture and Assembly Language
Unit:08 Software Interrupts
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
By Nasser Halasa Assembly Language.
Presentation transcript:

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

Josh PottsECE291 Outline Hardware I/O with ports 8253 Timer Parallel Port

Josh PottsECE291 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

Josh PottsECE291 IN/OUT Instructions Two forms of I/O device (ports) addressing –Fixed-port addressing allows data transfer using an 8-bit I/O port address –port number follows the instruction opcode IN AL, 6Ah;data from I/O address 6Ah are input to AL –Variable-port addressing allows data transfer using 16-bit port address –the I/O port number is usually stored in register DX, which can be changed during the execution of the program OUT 19h, AX ;transfers the contents of AX to I/O port 19h

Josh PottsECE291 IN/OUT Instructions (simple example). MODEL TINY.CODE.STARTUP INAL, 61h;read port 61h ORAL, 3 OUT61h, AL MOV CX, 1000h ;delay count; if the count is increased, the click will ;become longer L1: LOOP L1 INAL, 61h ANDAL, 0FCh OUT61h, AL;speaker is off.EXIT END

Josh PottsECE291 Keyboard The keyboard is controlled by microcontroller that contains a simple microprocessor The keyboard is connected to the 8255 chip (PPI- Programmable Peripheral Interface) –contains three registers A, B, and C 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 line of the PIC chip gets the scan code, sends the ACK to the PIC passes information to the keyboard buffer (a storage area in the BIOS data area)

Josh PottsECE291 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 –extended codes corresponding to special keys e.g., cursor key 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 Keyboard buffer holds keystrokes until read by INT 16

Josh PottsECE291 Programmable Interval Timer 8253 Intel 8253 contains 3 independent 16 bits programmable counters (timers) Operates under main timing pulse of Mz This frequency is divided by 12 before being sent to the timer so the basic pulses arrive at frequency Mz Timer 0 –Connected to IRQ0 line of the 8259 PIC (interrupt 08 –Counts from to zero –The output signal occurs each ( * 10 6 )/ = 18.2 Hz Timer 1 –Cause the DRAM memory system to be refreshed Timer 2 –Connected to a speaker

Josh PottsECE291 Programmable Interval Timer 8253 (cont.) 8253 is decoded at I/O ports with addresses 40h-43h Port Description 40h Timer 0 Count Register 41h Timer 1 Count Register 42h Timer 2 Count Register 43h Timer Control

Josh PottsECE291 Programmable Interval Timer 8253 (cont.) The control port 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/Load least significant byte 10: Read/Load most significant byte 11: Read/Load least significant byte then most significant byte 3,2,1 Count Mode (011=Square Wave) 0 Count Method: 0=Binary, 1=BCD

Josh PottsECE291 Speaker Control Timer Output from 8253 Gate control (port 61h, bit 1) Speaker Enable AND gate (port 61h, bit 0) Driver/Low-Pass Filter Speaker Write to Control Port MOV AL, b OUT 43h,AL 10: Control timer 2 11: Load Low Byte then High Byte 011: Select Square wave output 0: Count in binary

Josh PottsECE291 Speaker Control (cont.) Enable Speaker IN AL,61h OR AL, b OUT 61h,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)

Josh PottsECE291 Simple Tones Produced Using Square Wave CR EQU 13 LF EQU 10 extrn dosxit:near, kbdin:near, dspmsg:near, binasc:near ;====== SECTION 3: Define stack segment stkseg segment stack ; *** STACK SEGMENT db 64 dup ('STACK ') stkseg ends ;====== SECTION 4: Define code segment cseg segment public 'CODE' assume cs:cseg, ds:cseg, ss:stkseg, es:nothing ;====== SECTION 6: Main procedure pbuf db 7 dup(?) crlf db CR,LF,'$' freq_msg db ' Freq = $' count_msg db ' Hz, Count = $'

Josh PottsECE291 Simple Tones Produced Using Square Wave (cont.) main proc far mov ax, cseg ; 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

Josh PottsECE291 Simple Tones Produced Using Square Wave (cont.) mov cl,8 ; Freq * 256 (Hz) shl ax,cl mov dx,offset freq_msg call dspmsg mov bx,offset pbuf call binasc mov dx,offset 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,offset count_msg call dspmsg mov bx,offset pbuf call binasc

Josh PottsECE291 Simple Tones Produced Using Square Wave (cont.) mov dx,offset pbuf call dspmsg ; Print count mov dx,offset 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 endp cseg ends end main

Josh PottsECE291 Parallel Interface Originally Designed for printers Provides 8-bit I/O Provides TTL-level (5V) external I/O When the computer boots it detects any printer adapters and assigns ‘logical’ ports 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

Josh PottsECE291 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 cen be accesses by using DEBUG –you get the debug prompt (a minus sign) –type - d40:0008 (and hit return) –you get : 0040:0008BC ….. –the first six bytes are addresses of the installed printer adapters

Josh PottsECE291 Parallel Interface Major Signals Signal(s) Input/Output Notes Data[7:0] Bidirectional Byte-wide data bus Strobe To de Write signal Busy From device Don't send more data Ack From device Acknowledge (interrupt signal) Initialize To device Initialize external device Out of Paper From device Status signal

Josh PottsECE291 Writing To the Parallel Interface

Josh PottsECE291 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