Buffered, Interrupt-Driven Printer Design Example

Slides:



Advertisements
Similar presentations
10-1 EE 319K Introduction to Microcontrollers Lecture 10: Interrupts, Output Compare Periodic Interrupts Read Book Sections 9.1, 9.2, 9.4, 9.6.1, 9.6.2,
Advertisements

ELEC 330 Digital Systems Engineering Dr. Ron Hayne
ECE 447 Fall 2009 Lecture 9: TI MSP430 Interrupts & Low Power Modes.
68HC11 Polling and Interrupts
ECE 372 – Microcontroller Design Parallel IO Ports - Interrupts
Interrupts What is an interrupt? What does an interrupt do to the “flow of control” Interrupts used to overlap computation & I/O – Examples would be console.
Computer System Structures memory memory controller disk controller disk controller printer controller printer controller tape-drive controller tape-drive.
UNIT 8 Keypad Interface Contact Closure Counter Exceptions (Interrupts and Reset)
Accessing I/O Devices Processor Memory BUS I/O Device 1 I/O Device 2.
13-Nov-15 (1) CSC Computer Organization Lecture 7: Input/Output Organization.
6-1 EE 319K Introduction to Microcontrollers Lecture 6: Indexed Addressing Mode and Variants, Functional Debugging, Arrays, Strings.
ELE22MIC Lecture 8 ASll Examples –16 Bit Counters –Buffalo Jump Table Interrupt processing (IRQ/RTI) Stack Frame & Base Pointer Wired OR.
12/16/  List the elements of 8255A Programmable Peripheral Interface (PPI)  Explain its various operating modes  Develop a simple program to.
PPI-8255.
The Serial Communication Interface (SCI) MC9S12-C32
CS-280 Dr. Mark L. Hornick 1 Sequential Execution Normally, CPU sequentially executes instructions in a program Subroutine calls are synchronous to the.
Transmitter Interrupts Review of Receiver Interrupts How to Handle Transmitter Interrupts? Critical Regions Text: Tanenbaum
ELE22MIC Lecture 17 Writing 68HC11 software 68HC11 Main Timer System –Output Compare –What is different about TOC1?
Chapter 10 Interrupts. Basic Concepts in Interrupts  An interrupt is a communication process set up in a microprocessor or microcontroller in which:
Input/Output (I/O) Important OS function – control I/O
ELE22MIC Lecture 18 Writing 68HC11 software 68HC11 Main Timer System
Interrupts and exceptions
Mon Sept. 11 Announcements
Device Identification
Interfacing the HC(S)12 microcontroller to a Hitachi/Optrex LCD Display Panel The LCD display panel contains its own microcontroller (Hitachi HD44780)
Microprocessor Systems Design I
Fri. Sept 29 Announcements
Learning Outcome #1 Architecture and Programming Model
Mon. Oct 2 Announcements Quiz Postponed to Wednesday – still only on 2.a + 2.b Video lecture for 2.a posted Lab 6 experiment extension You must come to.
Lesson Objectives Aims Key Words Interrupt, Buffer, Priority, Stack
9S12C Multiplexed Bus Expansion
Computer Architecture
ELE22MIC Lecture 18 Writing 68HC11 software 68HC11 Main Timer System
Interrupts In 8085 and 8086.
Input/Output.
Buffered, Interrupt-Driven Printer Design Example
Lab Practical #1 Review Tim Rogers 2017.
Dr. Michael Nasief Lecture 2
Presentation On 8259 Made by Md Shabbir Hasan.
8086/8088 Hardware Specifications
Programmable Interrupt Controller 8259
“Assembly Table Lookup”
Chapter 8 Input/Output I/O basics Keyboard input Monitor output
8259 Chip The Intel 8259 is a family of Programmable Interrupt Controllers (PIC) designed and developed for use with the Intel 8085 and Intel 8086 microprocessors.
Serial Communications Interface (SCI)
Module 2.E Buffered I/O Tim Rogers 2017.
Module 2.E Buffered I/O Tim Rogers 2017.
Interrupt Driven I/O References Text: Tanenbaum ch.1.4.3, ch Receiver Interrupt Program Example:
Interfacing with I/O Devices
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
Computer System Overview
Graded Quiz #6 Oct. 13, 2017 Clicker [AB]
Interrupts Interrupt is a process where an external device can get the attention of the microprocessor. The process starts from the I/O device The process.
Parallel communication interface 8255
Processor Fundamentals
Operating Systems Chapter 5: Input/Output Management
Programmable Peripheral Interface
82C55 Programmable Peripheral Interface
Chapter 8 I/O.
8259 Programmable Interrupt Controller
Transmitter Interrupts
Lecture 9: TI MSP430 Interrupts & Low Power Modes
Interrupts.
Computer Architecture and Assembly Language
Interrupt-Driven State Machine
Interrupt handling Explain how interrupts are used to obtain processor time and how processing of interrupted jobs may later be resumed, (typical.
Chapter 8 I/O.
COMP3221: Microprocessors and Embedded Systems
The Programmable Peripheral Interface (8255A)
Assignment 1) Explain how lower address bus is multiplexed with data bus? 2) Explain the function of all the control signals in the 8085 Control Logic.
Presentation transcript:

Buffered, Interrupt-Driven Printer Design Example Module 2.F Buffered, Interrupt-Driven Printer Design Example Tim Rogers 2017

Learning Outcome #2 Bus Timing Analysis “An ability to interface a microcontroller to various devices” Bus Timing Analysis 9S12C Multiplexed Bus Expansion General-Purpose I/O Ports Interrupt Handling Buffered I/O Buffered, Interrupt-Driven Printer Design Example How?

Interrupts the CPU to consume characters – when its ready Objective “Buffered, Interrupt-Driven Printer Design Example” Interrupts the CPU to consume characters – when its ready Produces Characters

Review: Printer Handshaking What will happen when the interrupt occurs? (A) CPU copies a new character to the buffer (B) CPU copies next value from buffer to data bus  (C) Printer copies data off the data bus (D) Printer puts a new value on the buffer (E) Nothing What will happen when the interrupt occurs? (A) CPU copies a new character to the buffer (B) CPU copies next value from buffer to data bus (C) Printer copies data off the data bus (D) Printer puts a new value on the buffer (E) Nothing Review: Printer Handshaking When should the interrupt occur? (A) Strobe to low (B) Strobe to high (C) Busy to low  (D) Busy to high (E) When next char does on bus When should the interrupt occur? (A) Strobe to low (B) Strobe to high (C) Busy to low (D) Busy to high (E) When next char goes on bus 3 4 STROBE 1 5 BUSY 2 Previous Character Next Character DATA Interrupt here

What does it mean for the interrupt to be masked? Printer Interrupt Enable (PIE) Bit (from CPU) PIE has to be 1 for the interrupt to be asserted Flag Clear (From CPU) CLR Q IRQ (to CPU) 1 D Q Interrupt Request (From Device)

Example Circuit PIE

How to use PIE When buffer is empty: CPU has nothing to send When buffer has content: CPU has stuff waiting to send PIE=1

Life without PIE Printer will continuously trigger interrupt while busy is 0 If buffer is empty – printer never becomes busy STROBE BUSY Previous Character Last Character in Buffer DATA

Prof. Meyer calls this a “Digital Binky” Life with PIE When buffer empties: Set PIE=0 STROBE BUSY PIE Prof. Meyer calls this a “Digital Binky” Previous Character Last Character in Buffer DATA

How to use PIE When buffer is empty: CPU has nothing to send When buffer has content: CPU has stuff waiting to send PIE=1

Driver Declarations smask equ $02 ; STROBE mask imask equ $04 ; PIE enable mask cmask equ $08 ; flag clear mask psize equ 100 ; buffer size pbuf rmb psize; printer buffer pin fcb 0 ; printer IN ptr pout fcb 0 ; printer OUT ptr

Driver Initialization Routine smask equ $02 ; printer STROBE mask imask equ $04 ; printer intr en mask cmask equ $08 ; dev flag clear mask pinit movb #$FF,ddrx movb #$0E,ddry bset porty,cmask bclr porty,cmask ;assert FLG_CLR’ bset porty,cmask ;to initialize bclr porty,imask ;clear PIE bit clr portx ;ASCII null bset porty,smask bclr porty,smask ;assert STROBE’ bset porty,smask ;to initialize cli ;enable IRQ rts

Useful Macro Macro for incrementing B register mod BUFSIZE Example: incBmod 20 ; increments B modulo 20 incBmod MACRO incb cmpb #\1 bne $+3 clrb ENDM

Device Driver – API Application program interface that places characters in the printer buffer (the “producer”) 1. Check status of printer buffer 2. If FULL, wait for space 3. Else, put character in buffer at IN 4. Increment IN modulo BUFSIZE 5. Enable (“unmask”) printer interrupts 6. Exit

Device Driver – API ; Buffered printer spooler routine ; Character passed in A register placed in PBUF ; ; STEP (1) Check PBUF status bps ldab pin incBmod psize ;(B)=(PIN+1)mod PSIZE pshb ;save on stack ; STEP (2) If FULL, wait for space pwait cmpb pout ;perform FULL check beq pwait ;wait if PBUF full

Device Driver – API ; STEP (3) Put character in PBUF at IN ldx #pbuf ldab pin staa b,x ;PBUF[PIN] = (A) ; STEP (4) Increment IN modulo PSIZE pulb ;retrieve from stack stab pin ;PIN=PIN+1 mod PSIZE ; STEP (5) Enable printer interrupts bset porty,imask ; STEP (6) Exit rts

Device Driver – ISR Interrupt service routine that outputs next character in buffer to the printer (the “consumer”) 1. Check status of printer buffer 2. If EMPTY, disable (“mask”) printer interrupts and exit 3. Else, clear printer device flag 4. Output character pointed to by OUT 5. Assert printer’s STROBE signal 6. Increment OUT modulo BUFSIZE 7. Exit

Device Driver – ISR ; Printer interrupt service routine ; ; STEP (1) Check PBUF status prisr ldab pout cmpb pin bne pok ;if not empty, print ; STEP (2) If buffer is empty, disable printer ; interrupts and exit bclr porty,imask rti

Device Driver – ISR ; Printer interrupt service routine ; ; STEP (3) Clear printer device flag pok bclr porty,cmask bset porty,cmask ; STEP (4) Output character pointed to by OUT ldx #pbuf ldaa b,x ;(A)=PBUF[POUT] staa portx

Device Driver – ISR ; Printer interrupt service routine ; ; STEP (5) Strobe printer bclr porty,smask bset porty,smask ; STEP (6) Increment OUT mod PSIZE incBmod psize stab pout ;POUT=(POUT+1) mod PSIZE ; STEP (7) Exit rti

1. Will Coach need a Digital Binky to make it through this B-ball season? A. yes B. no