9-1 EE 319K Introduction to Microcontrollers Lecture 9:I/O Synchronization; LCD Interfacing; Implementing Local Variables using a Stack Frame; Parameter.

Slides:



Advertisements
Similar presentations
Chapter 3 Basic Input/Output
Advertisements

Accessing I/O Devices Processor Memory BUS I/O Device 1 I/O Device 2.
Ch. 7 Local Variables and Parameter Passing From the text by Valvano: Introduction to Embedded Systems: Interfacing to the Freescale 9S12.
680XX Program Examples Outline –Binary to BCD –Matrix Addition –Ones Count –String Compare –Sector Map –Raster Graphics –Subroutine Calls Goal –Understand.
EECC250 - Shaaban #1 Lec # 6 Winter Stack-Related Instructions PEA Push Effective Address Calculates an effective address and pushes it.
1/1/ / faculty of Electrical Engineering eindhoven university of technology Architectures of Digital Information Systems Part 1: Interrupts and DMA dr.ir.
I/O Unit.
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,
CS-334: Computer Architecture
1/1/ / faculty of Electrical Engineering eindhoven university of technology Introduction Part 3: Input/output and co-processors dr.ir. A.C. Verschueren.
Avishai Wool lecture Introduction to Systems Programming Lecture 8 Input-Output.
1 Lecture 2: Review of Computer Organization Operating System Spring 2007.
Other I/O LCD display Flash ROM Keyboard (PS/2) UART connectors.
Basic Input/Output Operations
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.
Chapter 7 Input/Output. Input/Output Problems Wide variety of peripherals —Delivering different amounts of data —At different speeds —In different formats.
Unit-5 CO-MPI autonomous
Group 7 Jhonathan Briceño Reginal Etienne Christian Kruger Felix Martinez Dane Minott Immer S Rivera Ander Sahonero.
Overview What kind of LCD Interfacing the LCD Displaying Text and Numbers Common Issues.
Digital Outputs LCD Display
Chapter 8 Input/Output l I/O basics l Keyboard input l Monitor output l Interrupt driven I/O l DMA.
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:
System Calls 1.
Chapter 10: Input / Output Devices Dr Mohamed Menacer Taibah University
Dr. Rabie A. Ramadan Al-Azhar University Lecture 6
Input and Output Computer Organization and Assembly Language: Module 9.
MICROPROCESSOR INPUT/OUTPUT
Interrupts and DMA CSCI The Role of the Operating System in Performing I/O Two main jobs of a computer are: –Processing –Performing I/O manage and.
Spring EE 437 Lillevik 437s06-l8 University of Portland School of Engineering Advanced Computer Architecture Lecture 8 Project 3: memory agent Programmed.
1. Introduction 2. Methods for I/O Operations 3. Buses 4. Liquid Crystal Displays 5. Other Types of Displays 6. Graphics Adapters 7. Optical Discs 10/01/20151Input/Output.
CP104 Introduction to Programming File I/O Lecture 33 __ 1 File Input/Output Text file and binary files File Input/output File input / output functions.
Khaled A. Al-Utaibi  Interrupt-Driven I/O  Hardware Interrupts  Responding to Hardware Interrupts  INTR and NMI  Computing the.
Objectives Implement pointers using indexed addressing modes Use pointers to access arrays, strings, structures, tables, and matrices Present finite-state.
Computer Architecture Lecture10: Input/output devices Piotr Bilski.
Microcode Source: Digital Computer Electronics (Malvino and Brown)
Computers Internal Communication. Basic Computer System MAIN MEMORY ALUCNTL..... BUS CONTROLLER Processor I/O moduleInterconnections BUS Memory.
I/O Interfacing A lot of handshaking is required between the CPU and most I/O devices. All I/O devices operate asynchronously with respect to the CPU.
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.
Microprocessor. Interrupts The processor has 5 interrupts. CALL instruction (3 byte instruction). The processor calls the subroutine, address of which.
Lecture 2 Microprocessor Architecture Image from:
ELE22MIC Lecture 8 ASll Examples –16 Bit Counters –Buffalo Jump Table Interrupt processing (IRQ/RTI) Stack Frame & Base Pointer Wired OR.
Chapter 3 Basic Input/Output. Chapter Outline Basic I/O capabilities of computers I/O device interfaces Memory-mapped I/O registers Program-controlled.
Fall 2000M.B. Ibáñez Lecture 25 I/O Systems. Fall 2000M.B. Ibáñez Categories of I/O Devices Human readable –used to communicate with the user –video display.
3-1 EE 319K Introduction to Microcontrollers Lecture 3: Addressing modes, Memory Operations, Subroutines, I/O, Logical/Shift Operations.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
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.
8-1 EE 319K Introduction to Microcontrollers Lecture 8:Fixed Point Numbers, Local Variables, Binding, Allocation, Access, Deallocation.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
Lecture 1: Review of Computer Organization
Department of Electronic & Electrical Engineering LCD character display (parallel interface). How to interface a LCD character display to a PIC.
بسم الله الرحمن الرحيم MEMORY AND I/O.
CPS 4150 Computer Organization Chapter 2-2 Fall 2006 Ching-Song Don Wei.
1 Device Controller I/O units typically consist of A mechanical component: the device itself An electronic component: the device controller or adapter.
5-1 EE 319K Introduction to Microcontrollers Lecture 5: Conditionals, Loops, Modular Programming, Sub- routines, Parameter passing.
Chapter 12 Processor Structure and Function. Central Processing Unit CPU architecture, Register organization, Instruction formats and addressing modes(Intel.
Architectures of Digital Information Systems Part 1: Interrupts and DMA dr.ir. A.C. Verschueren Eindhoven University of Technology Section of Digital.
Introduction of microprocessor
E3165 DIGITAL ELECTRONIC SYSTEM
Chapter 8 Input/Output I/O basics Keyboard input Monitor output
Instructions - Type and Format
Final Exam Review Department of Electrical and Computer Engineering
Operating Systems Chapter 5: Input/Output Management
Md. Mojahidul Islam Lecturer Dept. of Computer Science & Engineering
Md. Mojahidul Islam Lecturer Dept. of Computer Science & Engineering
Some Assembly (Part 2) set.html.
Some Assembly
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:

9-1 EE 319K Introduction to Microcontrollers Lecture 9:I/O Synchronization; LCD Interfacing; Implementing Local Variables using a Stack Frame; Parameter Passing

9-2 Ramesh Yerraballi I/O Synchronization Blind Cycle Counting Synchronization Blind cycle counting is appropriate when the I/O delay is fixed and known. This type of synchronization is blind because it provides no feedback from the I/O back to the computer. Gadfly or Busy Waiting Synchronization Check busy/ready flag over and over until it is ready Interrupt Synchronization Request interrupt when busy/ready flag is ready

9-3 Ramesh Yerraballi Input Sync Busy-wait: S/W must wait for the i/p device to be ready Synchronizing with an i/p device

9-4 Ramesh Yerraballi Output Sync Busy-wait: S/W must wait for the o/p device finish the previous operation Synchronizing with an o/p device

9-5 Ramesh Yerraballi LCD Interface Parallel port LCD interface with the HD44780 Controller

9-6 Ramesh Yerraballi Access Cycles There are four types of access cycles to the HD44780 depending on RS and R/W(Control signals) RSR/WCycle 00Write to Instruction Register 01Read Busy Flag (bit 7) 10Write data from µP to the HD Read data from HD44780 to the µP

9-7 Ramesh Yerraballi Programming the LCD interface 4-bit protocol write command (outCsr) 1.E=0, RS=0 2.4-bit DB7,DB6,DB5,DB4 = most sig nibble of command 3.E=1 4.E=0 (latch 4-bits into LCD) 5.4-bit DB7,DB6,DB5,DB4 = least sig nibble of command 6.E=1 7.E=0 (latch 4-bits into LCD) 8.blind cycle 90 us wait

9-8 Ramesh Yerraballi Programming the LCD interface 4-bit protocol write ASCII data (LCD_OutChar) 1.E=0, RS=1 2.4-bit DB7,DB6,DB5,DB4 = most significant nibble of data 3.E=1 4.E=0 (latch 4-bits into LCD) 5.4-bit DB7,DB6,DB5,DB4 = least significant nibble of data 6.E=1 7.E=0 (latch 4-bits into LCD) 8.blind cycle 90 us wait

9-9 Ramesh Yerraballi LCD Programming

9-10 Ramesh Yerraballi 4-bit Interface

9-11 Ramesh Yerraballi Operations Clear display ;1)outCsr($01) causes Clear ;2)blind cycle 1.64ms wait ;3)outCsr($02) sends the Cursor to home ;4)blind cycle 1.64ms wait Move cursor to ;1)outCsr(DDaddr+$80) first row (left-most 8) DDaddr is 0 to 7 second row (right-most 8) DDaddr is $40 to $47

9-12 Ramesh Yerraballi Fonts Define up to 8 new fonts // font is the font number 0 to 7 // n0-n7 is the 5 by 8 pixel map CGaddr=((font&0x07)<<3)+0x40; outCsr(CGaddr); // set CG RAM address LCD_OutChar(n0); LCD_OutChar(n1); LCD_OutChar(n2); LCD_OutChar(n3); LCD_OutChar(n4); LCD_OutChar(n5); LCD_OutChar(n6); LCD_OutChar(n7); outCsr(0x80); // revert back to DD RAM

9-13 Ramesh Yerraballi Fonts Example Say we want to store the following graphic (pixel configuration) in font number 5 // n0 = $00 // █ █ n1 = $11 // █ █ █ █ █ n2 = $1F // █ █ █ n3 = $15 // █ █ █ n4 = $15 // █ █ █ n5 = $15 // █ █ █ n6 = $0E // █ n7 = $04 // set font=5 to this graphic // CGaddr=((5&0x07)<<3)+0x40 = $68 outCsr(0x68); // set CG RAM address LCD_OutChar(0x00); LCD_OutChar(0x11); LCD_OutChar(0x1F); LCD_OutChar(0x15); LCD_OutChar(0x0E); LCD_OutChar(0x04); outCsr(0x80); // revert back to DD RAM // To output this graphic LCD_OutChar(5);

9-14 Ramesh Yerraballi LCD_OutFix 0) save any registers that will be destroyed by pushing on the stack 1) allocate local variables letter and num on the stack 2) initialize num to input parameter, which is the integer part 3) if number is less or equal to 999, go the step 6 4) output the string “*.** “ calling LCD_OutString 5) go to step 19 6) perform the division num/100, putting the quotient in letter, and the remainder in num 7) convert the ones digit to ASCII, letter = letter+$30 8) output letter to the LCD by calling LCD_OutChar 9) output ‘.’ to the LCD by calling LCD_OutChar 10)perform the division num/10, putting the quotient in letter, and the remainder in num 11)convert the tenths digit to ASCII, letter = letter+$30 12)output letter to the LCD by calling LCD_OutChar 13)convert the hundredths digit to ASCII, letter = num +$30 14)output letter to the LCD by calling LCD_OutChar 15)output ‘ ‘ to the LCD by calling LCD_OutChar 16)deallocate variables 17)restore the registers by pulling off the stack

9-15 Ramesh Yerraballi Local Variables on Stack: Using Stack Frame org $4000 ; calculate sum of numbers ; Input: RegD num ; Output: RegD Sum of 1,2,3,...,num ; Errors: may overflow ; 1) binding sum set -4 ;16-bit accumulator num set -2 ;loop counter 1,2,3 calc ; 2) allocation pshx ;save old frame tsx ;create frame pshd ;allocate num movw #0,2,-sp ;sum=0 ; 3) access ;Stack picture relative to frame ; X-4 -> sum ; X-2 -> num ; X -> oldX ; X+2 -> return address loop ldd sum,x addd num,x std sum,x ;sum = sum+num ldd num,x subd #1 std num,x ;num = num-1 bne loop ldd sum,x ;result ; 4) deallocate txs pulx ;restore old frame rts

9-16 Ramesh Yerraballi Parameter Passing Input parameters  Data passed from calling routine into subroutine Output parameters  Data returned from subroutine back to calling routine Input/Output parameters  Data passed from calling routine into subroutine  Data returned from subroutine back to calling routine

9-17 Ramesh Yerraballi Parameter Passing call by reference how  A pointer to the object is passed why  Fast for passing lots of data  Simple to implement input/output parameters  both subroutine and calling routine assess same data call by value how  A copy of the data is passed why  Simple for small numbers of parameters  Protection of the original data from the subroutine

9-18 Ramesh Yerraballi Parameter Passing  We can pass parameters and store locals on stack, using a stack frame  Advantage: you can pass lots of data  Disadvantage: slower Strategy:  number of parameters?  few: use registers  a lot: use the stack  size of the parameter  1 or 2 bytes: call by value  buffers: call by reference  use call by reference for read/modify/write parameters