1 I/O and Interrupts Today: First Hour: I/O Concepts –Section 6.1-6.6 of Huang’s Textbook –In-class Activity #1 Second Hour: Interrupt Code Example –In-class.

Slides:



Advertisements
Similar presentations
Interrupts, Low Power Modes and Timer A (Chapters 6 & 8)
Advertisements

MC68HC11 System Overview. System block diagram (A8 version)
Programmable Keyboard/ Display Interface: 8279
TK2633 Introduction to Parallel Data Interfacing DR MASRI AYOB.
ELN5622 Embedded Systems Class 3 Spring, 2003 Kent Orthner
1/1/ / faculty of Electrical Engineering eindhoven university of technology Architectures of Digital Information Systems Part 1: Interrupts and DMA dr.ir.
External Interrupt Module MTT EXTERNAL INTERRUPT REQUEST MODULE (IRQ)
I/O Unit.
68HC11 Parallel I/O Chapter 7.
ELEC 330 Digital Systems Engineering Dr. Ron Hayne
1/1/ / faculty of Electrical Engineering eindhoven university of technology Introduction Part 3: Input/output and co-processors dr.ir. A.C. Verschueren.
68HC11 Polling and Interrupts
Introduction to Interrupts
EET 2261 Unit 9 Interrupts  Read Almy, Chapters 17 – 19.  Homework #9 and Lab #9 due next week.  Quiz next week.
ECE 372 – Microcontroller Design Parallel IO Ports - Interrupts
COMP3221: Microprocessors and Embedded Systems Lecture 15: Interrupts I Lecturer: Hui Wu Session 1, 2005.
6-1 I/O Methods I/O – Transfer of data between memory of the system and the I/O device Most devices operate asynchronously from the CPU Most methods involve.
ECE200 – Computer Organization Chapter 8 – Interfacing Processors and Peripherals.
Midterm Tuesday October 23 Covers Chapters 3 through 6 - Buses, Clocks, Timing, Edge Triggering, Level Triggering - Cache Memory Systems - Internal Memory.
1 Interrupts INPUT/OUTPUT ORGANIZATION: Interrupts CS 147 JOKO SUTOMO.
ECE 265 – LECTURE 12 The Hardware Interface 8/22/ ECE265.
Interrupts. 2 Definition: An electrical signal sent to the CPU (at any time) to alert it to the occurrence of some event that needs its attention Purpose:
Khaled A. Al-Utaibi  Intel Peripheral Controller Chips  Basic Description of the 8255  Pin Configuration of the 8255  Block Diagram.
UNIT 8 Keypad Interface Contact Closure Counter Exceptions (Interrupts and Reset)
Ch. 9 Interrupt Programming and Real-Time Sysstems From Valvano’s Introduction to Embedded Systems.
Input/Output mechanisms
Week #5 General Interfacing Techniques
Chapter 6: Interrupts and Resets
Dr. Rabie A. Ramadan Al-Azhar University Lecture 6
Revised: Aug 1, ECE 263 Embedded System Design Lessons 23, 24 - Exceptions - Resets and Interrupts.
MICROPROCESSOR INPUT/OUTPUT
Nurudeen Olayiwola Thomas Gutierrez
Khaled A. Al-Utaibi  Interrupt-Driven I/O  Hardware Interrupts  Responding to Hardware Interrupts  INTR and NMI  Computing the.
ME 4447/6405 Interrupts and Resets Suzanne Price Scott Gilliliand Greg Graf.
Interrupts and reset operations. Overview  Introduction to interrupts – What are they – How are they used  68HC11 interrupt mechanisms – Types of interrupts.
ELE22MIC Lecture 15 Applications of Parallel Input Output (I/O)
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.
1 68HC11 Timer Chapter HC11 Timer Subsystem Several timing functions: Basic timing Basic timing Real time interrupts Real time interrupts Output.
ELE22MIC Lecture 8 ASll Examples –16 Bit Counters –Buffalo Jump Table Interrupt processing (IRQ/RTI) Stack Frame & Base Pointer Wired OR.
George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ME 4447/6405 Microprocessor Control of Manufacturing Systems and Introduction.
1 Interrupts, Resets Today: First Hour: Interrupts –Section 5.2 of Huang’s Textbook –In-class Activity #1 Second Hour: More Interrupts Section 5.2 of Huang’s.
Programmable Peripheral Interface Parallel port Interface 8255
I/O Ports MTT I/O PORTS. I/O Ports MTT Module Objectives Configure any pin as either input or output Read or write data from/to port.
1 Stacks, Subroutines, I/O Routines Today: First Hour: Stacks, Subroutines –Section 3.9,3.10 of Huang’s Textbook –In-class Activity #1 Second Hour: I/O.
Motorola MC68HC811E2 Microcontrollers
12/16/  List the elements of 8255A Programmable Peripheral Interface (PPI)  Explain its various operating modes  Develop a simple program to.
Module 11 Adapted By and Prepared James Tan © 2001.
1 68HC11 Timer HC11 or HC12: Chapter HC11 Timer Subsystem  Several timing functions: Basic timing Basic timing Real time interrupts Real time.
Parallel I/O. Introduction This section focuses on performing parallel input and output operations on the 68HC11 3 operation types – Simple, blind data.
1 Expanded Modes, Bus, External Memory Today: First Hour: Expanded Modes, Bus, Timing –Section of Huang’s Textbook –In-class Activity #1 Second.
بسم الله الرحمن الرحيم MEMORY AND I/O.
1 Bringing it all together: Exploring the EVB Today: First Hour: Bringing it all together by exploring the EVB –Section of Huang’s Textbook.
George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ME 4447/6405 Microprocessor Control of Manufacturing Systems and Introduction.
CS-280 Dr. Mark L. Hornick 1 Sequential Execution Normally, CPU sequentially executes instructions in a program Subroutine calls are synchronous to the.
1 Bringing it all together: Exploring the EVB Today: First Hour: Bringing it all together by exploring the EVB –Section of Huang’s Textbook.
George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ME 4447/6405 Microprocessor Control of Manufacturing Systems and Introduction.
ELE22MIC Lecture 17 Writing 68HC11 software 68HC11 Main Timer System –Output Compare –What is different about TOC1?
HCS12 Exceptions Maskable Interrupts
ECE 3430 – Intro to Microcomputer Systems
ECE 3430 – Intro to Microcomputer Systems
68HC11 Interrupts & Resets.
Microprocessor Systems Design I
ECE 3430 – Intro to Microcomputer Systems
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.
General Purpose I/O.
CNET 315 Microprocessor & Assembly Language
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
Presentation transcript:

1 I/O and Interrupts Today: First Hour: I/O Concepts –Section of Huang’s Textbook –In-class Activity #1 Second Hour: Interrupt Code Example –In-class Activity #2

2 Goal: Example Task Read the output of the 4-bit data source every time the push button is pressed, and display the result. 4-bit Data Source Push Button Computer (HC11 chip) Display

3 ROM-8KB RAM-256 bytes EEPROM-512 bytes PORT A PULSE ACCUMULATOR PERIODIC INTERRUPT COP WATCHDOG PAI OC2 OC3 OC4 OC5 O C 1 IC1 IC2 IC3 PA7 PA6 PA5 PA4 PA3 PA2 PA1 PA0 PE7 PE6 PE5 PE4 PE3 PE2 PE1 PE0 PORT E V REFH V REFL A/D CONVERTER DATA DIRECTION PORT D SS SCK MOSI MISO SPI TxD RxD SCI PD5 PD4 PD3 PD2 PD1 PD0 M68HC11 CPU ADDRESS DATA BUS INTERRUPTS RESET XIRQ IRQ (V PPBULK ) 1 A 1 0 A 9 A 8 A D 7 A D 6 A D 5 A D 4 A D 3 A D 2 A D 1 A D 0 R/W AS EXPAND OSCILLATOR XTAL EXTAL E MODA LIR MODB (V STBY ) V DD V SS MODE SELECT POWER M6811 Ports

4 Ports Way to read/write from/to peripheral devices Some ports allow both input and output (see your PRG!) Each port has: –Control Registers –Status Registers –Data Registers –Data Direction Registers The ports are memory mapped, which means that you can access these registers via memory! –I/O becomes a simple matter of reading/writing to these special memory locations!

5 Look up PRG! -The 68HC11A8 has 40 I/O pins that are arranged in five I/O ports. -All I/O pins serve multiple functions. -Ports C and D are bi-directional I/O pins under the control of their associated data direction registers. -Port C, port B, the STRA pin, and the STRB pin are used for strobed and handshake parallel I/O, as well as for general-purpose I/O. Port Registers -To input, the 68HC11 reads from the port data register -To output, the 68HC11 writes into the port data register -All except port C have one data register: PORTA (at $1000) PORTB (at $1004) PORTC (at $1003) PORTCL (at $1005) PORTD (at $1008) PORTE (at $100A) 6811 Parallel I/O Using Ports

6 -Each pin of ports C and D has an associated bit in a specific data register and another in a data direction register. -The primary direction of a pin is set by its associated bit in the data direction register. - When an output pin is read, the value at the input to the pin driver is returned. -The data direction registers are cleared by reset to configure all bi-directional I/O pins for input. -Before performing I/O operation to these two ports, the software should set up the data direction registers of these two ports. Data & Direction Registers

7 Display 4-bit Data Source PORTCPORTC DDRC Data & Direction Registers

8 Which PORTC pins are Input: Output: ? Which PORTC pins are Input: Output: ? Eg: Setting I/O Pin Directions PORTC Example Program Fragment PORTCEQU$1003 DDRCEQU$1007 IO_PATEQU% NUMBEREQU% LDAA#IO_PAT STAADDRC LDAA#NUMBER STAAPORTC LDAAPORTC [3:0] [7:4] What bit pattern is output: ? What bit pattern is output: ? %1001

9 REGBASEQU$1000 PORTDEQU$08 DDRDEQU$09 LDX#REGBAS LDAA#$3F; directions of port D pins STAADDRD,X LDAA#$CD; output $CD to port D STAAPORTD,X Eg: Output to Port D

10 -All strobed mode I/O and handshake I/O are controlled by this PIOC register Parallel I/O Control Register STAFSTAICWOMHNDSOINPLSEGAINVB value after reset 00000U11 STAF: Strobe A flag. This bit is set when a selected edge occurs on the STRA signal. STAI: Strobe A interrupt enable. When the STAF and STAI bits are both equal to 1, a hardware interrupt request will be made to the CPU. EGA: Active edge for STRA 0: falling edge 1: rising edge INVB: Invert STRB 0: STRB active low 1: STRB active high PIOC at $

11 - Strobe is an external signal which can be used to trigger the I/O from the port. - Eg: Push botton ! Strobe Setup: -Strobe mode I/O selected when the bit 4 (HNDS) of the PIOC register is set to 0 and port C becomes a strobe input port. -The bit 1 (EGA) of the PIOC register when set to 1 selects the active edge of the STRA pin. - The active edge of the STRA signal latches the values of the port C pins into the PORTCL register. Strobe Input Port C

12 Strobe I/O Port C (Contd) -Reading the PORTC register returns the current values on the port C pins. -Reading the PORTCL register returns the contents of the latched PORTCL. -When enabled using bit 6 (STAI) of the PIOC, the active edge of the STRA signal will generate an interrupt to the 68HC11. -This interrupt shares the same vector as IRQ. -This can be used to force an interrupt-driven I/O !

13 Do Activity #1 Now Reference code REGBASEQU$1000 PORTDEQU$08 DDRDEQU$09 LDX#REGBAS LDAA#$3F; directions of port D pins STAADDRD,X LDAA#$CD; output $CD to port D STAAPORTD,X

14 Goal: Example Task Read the output of the 4-bit data source every time the push button is pressed, and display the result. 4-bit Data Source Push Button Computer (HC11 chip) Display

15 Recap: Polling Method 4-bit Data Source Push Button Computer (HC11 chip) Display START BUTTON PRESSED? 1 ms delay BUTTON PRESSED? READ 4-BIT INPUT UPDATE DISPLAY NO YES This style of computer input/output is called Polled I/O because we’re constantly polling the pushbutton This style of computer input/output is called Polled I/O because we’re constantly polling the pushbutton

16 Recap: Interrupt Method START INTERRUPT SERVICE ROUTINE READ THE 4-BIT INPUT UPDATE THE DISPLAY RETURN FROM INTERRUPT START INITIALIZE DO SOMETHING USEFUL Key Pressed The CPU is temporarily interrupted. An Interrupt Service Routine is entered The CPU is temporarily interrupted. An Interrupt Service Routine is entered The CPU now resumes where it left off! START INTERRUPT SERVICE ROUTINE READ THE 4-BIT INPUT UPDATE THE DISPLAY RETURN FROM INTERRUPT DO SOMETHING USEFUL

17 Interrupt Details RETURN FROM INTERRUPT (RTI) START Initialize Stack Setup Interrupt Vectors Clear previous interrupts & initialize device keeping interrupts disabled MAIN LOOP START INTERRUPT SERVICE ROUTINE Further identify source if needed Service interrupt Clear interrupt request flag* Enable interrupts locally at device Enable interrupts globally Identify source(s) Resolve priority Push registers Disable further interrupts Call interrupt service routine Restore registers Enable Interrupts Interrupt Request Done by hardware

18 Task: Hardware Setup The low nibble of PORTC is connected to a 7-segment display (output) The hi nibble of PORTC is connected to a 4-bit thumbwheel switch (input) The STRA line is connected to a high-asserting pushbutton Problem : –Copy thumbwheel setting to display whenever pushbutton is pressed. –This program should run on the EVB –Also illustrates the general form of programs using interrupts.

19 Code: initialization *Equates: define symbolic names for registers and constants PIOC EQU $1002 PORTC EQU $1003 DDRC EQU $1007 PORTCL EQU $1005 VECLOC EQU $00EE ; see EVB manual sec 3.3 the STRA line generates an IRQ interrupt JMPOP EQU $7E ; opcode for extended jmp IOPAT EQU $0F ; for data direction reg CTRPAT1 EQU % ; for PIOC reg, STAI disabled CTRPAT2 EQU % ; for PIOC reg, STAI enabled * Data Section - setup stack space and initial Stack Pointer ORG $D000 STACK RMB $7FF INITSP EQU *-1

20 Code: Init Port C * Setup and Initialization Program ORG $C000 * initialize stack pointer SETUPINT LDS #INITSP * initialize PORT C and associated control registers LDAA #CTRPAT1 ; STAI (temporarily) disabled STAA PIOC LDAA #IOPAT ; $0F => lower nibble output ; higher nibble input STAA DDRC CLR PORTC ; Clear Port C

21 Code: Setup Software IVT *setup interrupt vector in Buffalo jump table. *See section 3.3 of EVB manual for details. LDAA #JMPOP ; Load the Opcode for JMP ; at this vector location STAA VECLOC LDX #ISRIRQ ; Load the 16-bit RAM Address ; for the IRQ ISR (which is ; shared by STRA) in the next ; 2 bytes. STX VECLOC+1 ; Total:3 bytes per IVT location

22 Code: Enable Interrupts; Main *clear status of peripheral or subsystem that could cause *an immediate interrupt. See 6811 Reference manual Section 5.7, * Also see the textbook. LDAA PIOC LDAA PORTCL * Enable Interrupt in peripheral or subsystem LDAA #CTRPAT2 ; STAI enabled STAA PIOC * Enable Interrupts globally CLI; Clears I-bit in CCR. 0 => enable * Jump to main program JMP MAIN ****************************************************** * MAIN PROGRAM: trivial ****************************************************** MAIN BRA MAIN

23 Interrupt Service Routine On entry, all registers (incl. CCR with I bit) have been pushed on stack, and the I bit is set to 1 to mask further interrupts. * First check for valid interrupt. Branch to RTIIRQ if invalid. ISRIRQ LDX #PIOC BRCLR 0,X % ,RTIIRQ * Execute the unique recipe for clearing device interrupt flag LDAA PIOC LDAA PORTCL; Wacky !! * Service interrupt RORA RORA; Rotate 4 times RORA; Low nibble now has the 4 bits! STAA PORTC; Output to 7-segment display * Return from interrupt service routine RTIIRQ RTI ; restore registers and return to main * Note that this restores CCR (hence I bit), re-enabling interrupts. END

24 Do Activity #2 Now Due: End of Class Today. RETAIN THE LAST PAGE(S) (#3 onwards)!! For Next Class: Bring Huang Textbook, & HC11 PRG Required Reading: – Sec of Huang This reading is necessary for getting points in the Studio Activity!