UNIVERSITY OF HONG KONG DEPARTMENT OF ELECTRICAL AND ELECTRONIC ENGINEERING. Principles of Computer Operation

Similar documents
UNIVERSITY OF HONG KONG DEPARTMENT OF ELECTRICAL AND ELECTRONIC ENGINEERING

Roberto Muscedere Images and Text Portions 2003 Prentice Hall 1

Introduction to Computers - Chapter 4

EE 5340/7340 Motorola 68HC11 Microcontroler Lecture 1. Carlos E. Davila, Electrical Engineering Dept. Southern Methodist University

Microcomputer Architecture and Programming

The MC9S12 address, data and control buses The MC9S12 single-chip mode memory map Simplified write/read cycle. Address, Data and Control Buses


Using the MC9S12 in Expanded Mode External Ports S12CPUV2 Reference Manual Multiplexed External Bus Interface (MEBI) Module V3 Block User Guide

Basic Processing Unit: Some Fundamental Concepts, Execution of a. Complete Instruction, Multiple Bus Organization, Hard-wired Control,

Microprocessors/Microcontrollers

von Neumann Architecture Basic Computer System Early Computers Microprocessor Reading Assignment An Introduction to Computer Architecture

Basic Computer System. von Neumann Architecture. Reading Assignment. An Introduction to Computer Architecture. EEL 4744C: Microprocessor Applications

Mark II Aiken Relay Calculator

MICROPROCESSOR AND MICROCONTROLLER BASED SYSTEMS

1 MALP ( ) Unit-1. (1) Draw and explain the internal architecture of 8085.

MC68HC12 Parallel I/O

Training Kit for HP 1660/70 Series Logic Analyzers

ME4447/6405. Microprocessor Control of Manufacturing Systems and Introduction to Mechatronics. Instructor: Professor Charles Ume LECTURE 7

Chapter 1. Microprocessor architecture ECE Dr. Mohamed Mahmoud.

Z8 Pod Adapter. for the. Fluke 9000-Series Troubleshooter

Computer Architecture 2/26/01 Lecture #

AN1745. Interfacing the HC705C8A to an LCD Module By Mark Glenewinkel Consumer Systems Group Austin, Texas. Introduction

Microcontrollers. Microcontroller

Introduction to Microcontrollers

1. INTRODUCTION TO MICROPROCESSOR AND MICROCOMPUTER ARCHITECTURE:

1. Internal Architecture of 8085 Microprocessor

EEL 4744C: Microprocessor Applications. Lecture 7. Part 2. M68HC12 Interrupt. Dr. Tao Li 1

ECE L A B 1 Introduction ASSEMBLY PROGRAMMING WITH MINIIDE

Teaching and Curriculum Development of Microprocessor Classes

QUESTION BANK. EE 6502 / Microprocessor and Microcontroller. Unit I Processor. PART-A (2-Marks)

Basics of Microprocessor

EE319 K Lecture 3. Introduction to the 9S12 Lab 1 Discussion Using the TExaS simulator. University of Texas ECE

The Itanium Bit Microprocessor Report

CHAPTER 5 : Introduction to Intel 8085 Microprocessor Hardware BENG 2223 MICROPROCESSOR TECHNOLOGY

Module 5 - CPU Design

Go Gators! Relax! May the Schwartz be with you!

Handy Board Operations

CPE/EE 421/521 Fall 2004 Chapter 4 The CPU Hardware Model. Dr. Rhonda Kay Gaede UAH. The CPU Hardware Model - Overview

16COM / 40SEG DRIVER & CONTROLLER FOR DOT MATRIX LCD

2. List the five interrupt pins available in INTR, TRAP, RST 7.5, RST 6.5, RST 5.5.

Register Transfer and Micro-operations

Serial Communication Through an Asynchronous FIFO Buffer

Y = (A + C) (A + B) (B + C)

Ryerson Polytechnic University Department of Electrical Engineering COE328 Digital Systems. (2 Weeks) FORMAL REPORT - 30 Marks Due Date: Week 13

Introduction to CPU architecture using the M6800 microprocessor

Question Bank Microprocessor and Microcontroller

SCRAM Introduction. Philipp Koehn. 19 February 2018

Introduction to Microcontrollers

CHALMERS Lindholmen 1. Compare (a) a sand hour glass, (b) a pocket mechanical watch (c) a wrist quartz watch and (d) the Big

Parallel and Serial Bus Analysis Instructor s Guide

CREATED BY M BILAL & Arslan Ahmad Shaad Visit:

COMPUTER ARCHITECTURE AND ORGANIZATION Register Transfer and Micro-operations 1. Introduction A digital system is an interconnection of digital

Control Unit: The control unit provides the necessary timing and control Microprocessor resembles a CPU exactly.

ENGG3380: Computer Organization and Design Lab5: Microprogrammed Control

3.1 Description of Microprocessor. 3.2 History of Microprocessor

History of the Microprocessor. ECE/CS 5780/6780: Embedded System Design. Microcontrollers. First Microprocessors. MC9S12C32 Block Diagram

Computers and Microprocessors. Lecture 34 PHYS3360/AEP3630

538 Lecture Notes Week 1

MC68705P3 Bootstrap ROM

Ali Karimpour Associate Professor Ferdowsi University of Mashhad

Computer Organization I. Lecture 28: Architecture of M68HC11

Microcontroller Systems. ELET 3232 Topic 11: General Memory Interfacing

Introduction to Embedded Systems and Chapter 1: Introduction to HCS12/MC9S12. EE383: Introduction to Embedded Systems University of Kentucky

Dec Hex Bin ORG ; ZERO. Introduction To Computing

1. Internal Architecture of 8085 Microprocessor

CPU ARCHITECTURE. QUESTION 1 Explain how the width of the data bus and system clock speed affect the performance of a computer system.

Chapter Operation Pinout Operation 35

Total: EEL 3701 Digital Logic & Computer Systems Final Exam Fall Semester 2007 COVER SHEET: Re-Grade Information: 1 (10) 2 (10) 3 (10) 4 (14) 5 (14)

Ali Karimpour Associate Professor Ferdowsi University of Mashhad

EE 3170 Microcontroller Applications

e-pg Pathshala Subject : Computer Science Paper: Embedded System Module: 8051 Architecture Module No: CS/ES/5 Quadrant 1 e-text

Lab 16: Data Busses, Tri-State Outputs and Memory

address ALU the operation opcode ACC Acc memory address

History and Basic Processor Architecture

Programming the Motorola MC68HC11 Microcontroller

Topic #6. Processor Design

CPE/EE 421 Microcomputers

ENGIN 112 Intro to Electrical and Computer Engineering

Microcontroller Systems

Z Z-280 MT8930, MT8992/3/4/5 MT8880 MT8888 MT8889 MT8980/1 MT8985, MT8986 (DIP-40) MT8986 (PLCC-44) MT8920B MT8952B

Getting Started with the HCS12 IDE


538 Lecture Notes Week 5

Summer 2003 Lecture 21 07/15/03

EC4205 Microprocessor and Microcontroller

1 Digital tools. 1.1 Introduction

Chapter 1: Basics of Microprocessor [08 M]

In this lecture, we will look at how storage (or memory) works with processor in a computer system. This is in preparation for the next lecture, in

Computer Architecture Programming the Basic Computer

COSC 243. Computer Architecture 1. COSC 243 (Computer Architecture) Lecture 6 - Computer Architecture 1 1

EE 308 Spring Lecture 28 March 30, 2012 Review for Exam 2. Introduction to the MC9S12 Expanded Mode

1. Internal Architecture of 8085 Microprocessor

EE 308 Spring Lab on IIC Bus

CHAPTER TWELVE - Memory Devices

EE 3170 Microcontroller Applications

M. Sc (CS) (II Semester) Examination, Subject: Computer System Architecture Paper Code: M.Sc-CS-203. Time: Three Hours] [Maximum Marks: 60

MicroProcessor. MicroProcessor. MicroProcessor. MicroProcessor

16COM / 80SEG DRIVER & CONTROLLER FOR DOT MATRIX LCD

The 9S12 in Expanded Mode - How to get into expanded mode Huang Chapter 14

MC68705U3 Bootstrap ROM

Transcription:

UNIVERSITY OF HONG KONG DEPARTMENT OF ELECTRICAL AND ELECTRONIC ENGINEERING Experiment PCO: Principles of Computer Operation Location: Part I Lab., CYC 102. Objective: The objective is to learn the basic principles of computer operation. A simple micro-controller system is used for illustration. The process of fetching and executing instructions is studied by using a logic analyzer to examine bus activities and signals. Apparatus: Computer and software: An IBM PC, an M68HC11 micro-controller board, a debugging software, and a downloader. Equipment: Logic analyzer (Agilent mixed signal oscilloscope MSO6034A), and a dc power supply unit. Introduction: A simplified block diagram of a micro-processor system is given in Fig. 1. A brief introduction is given below. Please refer to the lecture notes and textbook for more details. Memory Contains program codes and data. A program consists of a sequence of instructions. Program Counter (PC) It is a register that contains the address of the next instruction byte to be fetched from memory into the CPU. The control unit (timing & control block) sends the necessary enable signals to the PC to place the PC's content onto the address bus. The PC's content is then incremented automatically to point to the next instruction byte in memory. Data Address Register (DAR) It holds the address of the operand to be fetched from memory into the CPU. Again the control unit provides the signals to place DAR's content onto the address bus. Page 1 of 12

(Control unit) Fig. 1 Block diagram of a micro-processor system Instruction Register (IR) and Control Unit To fetch an op-code from memory, the control unit generates signals to (i) put the content of the PC (= address of the op-code byte) onto the address bus, and (ii) set R/W'=1 to initiate a read from memory. With the given address, the memory unit gets the op-code byte from the memory cells, and puts the byte onto the data bus. The control unit generates signals to copy the byte into the Instruction Register (IR). Hence the IR contains the op-code. The decoder circuit decodes the op-code, and signals the control unit to generate the required sequence of control signals to complete the execution of the given instruction. Information about the sequence of control signals to be generated (called a microprogram) is stored in the control unit. Accumulator (A) & Data Register (DR) Page 2 of 12

The operands to be operated on are read from memory and copied into these two registers. The ALU then performs the required operation and the result is put into accumulator A. Execution of a program As an example, let the instruction to be fetched and executed be LDAA $1080 ; read the operand at memory address $1080 into accumulator A Since the op-code for LDAA is $B6, the complete instruction is coded as $B61080. Let the instruction be stored at memory address $00A0. Hence the memory contains: Address (Hex) Content (Binary) Content (Hex) 00A0 10110110 B6 (op-code) 00A1 00010000 10 (operand address) 00A2 10000000 80 (operand address)...... 1080 operand operand Steps to execute this instruction: 1. The PC contains the instruction address $00A0. The control unit loads this address onto the address bus and asserts the R/W' (read) signal. The memory unit puts the addressed byte onto the data bus and the control unit gets it into the Instruction Register. The byte obtained is $B6. The CPU treats it as the op-code. The PC is incremented by 1. 2. The control unit decodes this op-code and finds it to be LDAA. Hence it knows the operand address is stored at the next two memory addresses. So it fetches the byte from memory at address $00A1 into the Data Address Register. The byte obtained is $10 which is treated as the higher byte of the operand address. The PC is incremented by 1. 3. A further memory read at address $00A2 is performed to read the lower byte of the operand address which is $80. The complete operand address is thus $1080 which is stored in the Data Address Register of the CPU. The PC is incremented by 1. 4. The control unit fetches the operand byte from memory at address $1080 into Accumulator A. Execution of the instruction ends. After executing the current instruction, the CPU fetches the next instruction, decodes and executes it. This continues until all instructions in the program have been executed. In summary, the phases of executing an instruction are: 1. Instruction fetch 2. Instruction decode 3. operand fetch 4. execution 5. store back result (if needed). Page 3 of 12

Experimental Circuit: A board with an MC68HC11 micro-controller is used in this experiment. The board contains a number of peripheral devices. However, for the present purpose, only the memory circuit is relevant, as given in Fig. 2. Since the lower address byte A7...A0 and data byte D7...D0 are time-multiplexed, an address latch 74HC373, which consists of 8 level-triggered D-type flip-flops, is used to provide a stable address. The AS (address strobe) signal from the micro-controller is used to activate the latch. When AS is high, the CPU outputs an address, and the output pins Q7...Q0 of the 74HC373 contains the address. When AS goes low, the address at Q7...Q0 is locked and remains unchanged until the next AS pulse arrives. A 32-kbyte memory chip 62256 is connected. Memory is accessed by using the signals R/W' and E. Timing of the bus signals is illustrated in Fig.3. Address latch 62256 32-kByte SRAM Connect jumpers for bootstrap mode Fig. 2 Schematic diagram of a micro-controller system Page 4 of 12

Fig. 3 CPU read timing The reading operation as illustrated in Fig. 3 consists of the following steps. 1. At the rising edge of AS (Point 1), the CPU sets R/W' to 1 to indicate read, and puts the address on the pins of Ports B and C. 2. If the memory read is an instruction fetch, the PC is incremented at the rising edge of PH2 (Point 2). 3. At the falling edge of AS (Point 3), the address bits A0-A7 are latched, and the address bus holds the 16-bit address until the next AS pulse arrives. 4. At the rising edge of E-clock (Point 4), the selected memory or I/O device is enabled, and the device begins putting data onto the data bus. After a while, valid data appears on the data bus. 5. At the falling edge of the E-clock (Point 5), the CPU latches the data from the data bus into its internal register such as the instruction register. Page 5 of 12

Main theme of this experiment In this experiment, a sample program is to be downloaded into the memory chip of the micro-controller board and executed. A logic analyzer is used to probe the signals on the address, data and control buses. By looking at the signals, the instruction fetch and execution cycles can be readily appreciated. Sample program The sample program is given in Appendix 1. The program starts at address $8080. It consists of only a few instructions which repeatedly reads and writes memory address $B0F0. To load the program to the target address, a 2-stage bootstrap process is adopted in our experiment. Upon reset, the primary bootstrap program in the micro-controller's internal ROM is executed. It starts communicating with the host PC through the RS232 port and downloads a secondary bootstrap program from the PC to address $0000 in the internal RAM of the micro-controller. After the download, the PC is set to zero and the secondary bootstrap program at address $0000 starts to execute. This program communicates with the host PC and downloads the user program to the memory chip on the micro-controller board. The 2-stage bootstrap process is needed because upon reset, the primary bootstrap program executes in special bootstrap mode in which only the internal RAM (512 bytes) of the micro-controller can be accessed. Since the user program in our case has to reside in external memory, a secondary bootstrap program is needed to switch the microcontroller to normal expanded mode (in which external memory can be accessed) and to load the user program to external memory. The secondary bootstrap program is given in Appendix 2. Since our user program is very short, for the sake of convenience, it is included inside the secondary bootstrap program so that it does not need to be downloaded from the host PC. Page 6 of 12

Procedure: 1. Copy the secondary bootstrap program sci_com2.asm as given in Appendix 2 into a text file in your PC. Assemble it using the THRSim11 software. Two files will be generated: sci_com2.lst and sci_com2.s19. The former is a listing file showing the assembled hex code while the latter contains the executable code in Motorola's S19 text format. 2. Connect the micro-controller board to the COM1 port of the PC using the RS232 cable. Connect a 12-V dc supply to the board's power supply jack. Switch off the power supply unit and throw the power switch on the board to the OFF position. 3. We need to observe 19 digital signals. Since there are only 16 logic probes on the mixed signal oscilloscope, we have to use 3 analogue probes as well. Connect the probes to the signal pins on the board as follows: Analogue channel 1: AS (address strobe) Analogue channel 2: E Analogue channel 3: R/W' (read/write') Digital channels 8-15: A8, A9,..., A15 Digital channels 0-7: AD0, AD1,..., AD7 Gnd: Ground (note that each of the two pods and each analogue probe has a ground pin and ALL five pins have to be connected to ground) 4. Switch on the logic analyzer (mixed signal oscilloscope). Follow the procedure in Appendix 3 to set up the logic analyzer for capturing waveforms. 5. Switch on the dc power supply unit. However, keep the power switch on the microcontroller board in the OFF position. 6. Download the program to the micro-controller board as follows. Press the STOP button on the board and while keeping it pressed, throw the power switch to the ON position. The micro-controller undergoes a power-on reset cycle and executes the primary bootstrap program. The micro-controller is now ready to receive bytes from the host PC through the RS232 link. On the host PC, run the program m68download.exe. When prompted, enter the full path and name of the file (sci_com2.s19) to be downloaded to the board. Press the ENTER key. The program code will be downloaded to the micro-controller board. After downloading, the program on the micro-controller board will be executed automatically. 7. Run the logic analyzer by pressing the SINGLE button. The logic analyzer will be triggered when the CPU reads from address $8087. Set the time base such that at least 4 complete bus cycles (E clock cycles) are displayed on the logic analyzer (a suitable setting is 200ns/division and 850 ns delay). Study the 19 waveforms. Identify the 4 bus cycles beginning at the triggering point. Compare with the read cycle timing diagram of the M68HC11 (Fig. 3 of this instruction sheet). Page 7 of 12

8. It is convenient if the 16 address values can be displayed in Hex notation. This can be done as follows. Press the "D15 Thru D0" button. On the bottom of the screen, press the BUS softkey. Select BUS1 by turning the knob situated below the clockwise arrow on the panel. Then press the BUS1/BUS2 softkey to switch on BUS1. Use the softkeys on the bottom of the screen to select channels D15-D8 and D7-D0 for inclusion into BUS1. The binary values for the 16 address signals should now be displayed as hex values for BUS1 at the bottom of the screen. You can label BUS1 as AD. 9. Check that the address and data signals are as expected (refer to the list file sci_com2.lst for the codes that should appear on the address and data buses). 10. Measure the time between the correct address appearing on the address bus to the time valid data appearing on the data bus. 11. Save the waveforms on the screen to a bitmap file as follows. Plug in a USB thumb drive on the front panel. Press the UTILITY button, then press the PRINT CONFIG softkey. Press the PRINT TO softkey and select the 24-bit BMP bitmap file format. Press the QUICK PRINT button. The waveform on the screen will be saved as a file in the USB drive. Report: 1. Paste the recorded waveform into the report. Explain which instruction of the program in Appendix 1 corresponds to the observed waveform. 2. Explain the waveforms by mapping each cycle to a different phase of execution of the target instruction. From the recorded waveforms, read the values on the address and data buses at various instants and compare them with the values expected from the execution of the target instruction. Is there any discrepancy? 3. Report the value of the time delay measured in Step 10 of the procedures. Which device causes this time delay? 4. Explain any difficulties encountered in the experiment. 5. Attach the listing file sci_com2.lst with your report. References: 1. R.J. Tocci and F.J. Ambrosio, Microprocessors and Microcomputers, 6 th Edition, Prentice Hall, 2003.. 2. M68HC11 Reference Manual 3. M68HC11 Technical Data. Page 8 of 12

Appendix 1: -- Sample Program * This program starts at address $8080, and * repeatedly writes and reads memory address $B0F0. ORG $8080 ;start of program ldaa #$55 ;get data to be stored loop staa $B0F0 ;store data to target address ldaa #$00 ;clear A ldaa $B0F0 ;read back data from target address bra loop ;repeat indefinitely Page 9 of 12

Appendix 2: -- Secondary Bootstrap Program (file: sci_com2.asm) * Upon reset, the primary bootstrap program in ROM is executed. Its job is * to download this secondary bootstrap program from the host PC into the * internal RAM of the micro-controller at address $0000. The secondary * bootstrap program is then executed. It in turn copies the user program * as given in Appendix 1 to external memory (at address $8080) and * initiates the execution of the user program. * * For the sake of convenience, the short user program is included in the * body of this secondary bootstrap program so that there is no need * to download the user program from the host PC. ORG $0000 ;start of RAM ext_mem equ $8080 ;address of instruction in external memory block equ $0080 ;address of instruction block to be copied hprio equ $3C ;hprio register lower nibble address start ldx #$1000 ;set X to register base address bset hprio,x $20 ;set micro-controller to expanded mode bclr hprio,x $40 ;set micro-controller to normal mode ldx #block ;pointer to local block code ldy #ext_mem ;pointer to external memory loop1 ldaa 0,x ;get one byte from local block staa 0,y ;store in external memory inx ;increment pointer iny ;increment pointer cpx #last ;reached the end of block? blo loop1 ;not yet, loop back for another transfer jmp ext_mem ;jump to execute code in external memory ORG block ;start of block code to be copied to external memory ldaa #$55 ;get data to be stored loop2 staa $B0F0 ;store data to target address ldaa #$00 ;clear A ldaa $B0F0 ;read back data from target address bra loop2 ;repeat indefinitely last equ * ;last address Page 10 of 12

Appendix 3: -- Procedure to set up the logic analyzer (mixed signal oscilloscope) for waveform capture 1. Connect the two logic pods (each with 8 logic probes) to the back of the logic analyzer. Switch on the logic analyzer. 2. Press the "D15 Thru D0" button. The 16 digital channels will be displayed on the screen. On the bottom of the screen, press the leftmost softkey to change the size of the digital display to half of the screen's height. Press the THRESHOLDS softkey. Select CMOS for channels D15-D8 and D7-D0. This sets the threshold voltages for logic 1 and 0 according to CMOS devices. 3. Turn on analogue channel 1 by pressing the button 1. Set the voltage scale to 5V per division for each channel. Check that the input impedance is set at 1 M Ohm (as shown at the bottom of the screen). Press the PROBE softkey (at the bottom of the screen). Check that the probe impedance ratio shown is the same as that marked on the probe. Now the screen should show 19 signal traces. 4. Label the channels as follows. Press the LABEL button. Then press the CHANNEL softkey. Select analogue channel 1 by turning the Selection Knob (near the top left corner of the panel, below the clockwise arrow). Label the channel as 'AS' by pressing the softkeys (press SPELL; turn the Selection Knob to select character A, press ENTER; repeat for character S, then press APPLY NEW LABEL). Similarly label analogue channels 2 and 3 as 'E' and 'R/W~' respectively. Label digital channels D0 to D7 as 'AD0' to 'AD7' respectively. Label digital channels D8 to D15 as 'A8' to 'A15' respectively. 5. Set the logic analyzer to operate in pattern trigger mode. Set the trigger pattern as follows by pressing the PATTERN button: D15, D14, D13,..., D0 = HLLL LLLL HLLL LHHH (L = low, H = high, i.e., set triggering address to $8087) Analogue channel 1 = falling edge (i.e., falling edge of AS) Analogue channel 2 = X (i.e., don't care for E) Analogue channel 3 = H (i.e., R/W' = 1 for read operation) Analogue channel 4 = X (i.e., don't care for the unconnected channel) Page 11 of 12

6. We need to set the threshold for deciding whether a logic signal is high or low. For the digital channels, this has already been done in Step 2 above. We need to set the thresholds for the analogue channels as follows. Press the CHANNEL softkey and select Analogue channel 1 by turning the Selection knob (below the clockwise arrow). Set the threshold level to 2.5V by turning the LEVEL knob (near to top right corner of the panel). The threshold voltage is shown on the top right corner of the screen. Similarly set the threshold for Analogue channel 3 to 2.5V. 7. Press the MODE button on the panel, then press the MODE softkey at the bottom of the screen. Select NORMAL MODE. The logic analyzer will be triggered if the 19 input signals are as specified (i.e., a read operation at address $8087). Problems with setup 1. Undo Auto-Scale In case you pressed the AUTOSCALE button and the displayed format is not acceptable, you may undo it by pressing the UNDO AUTOSCALE softkey. It will return to the configuration immediately before the AUTOSCALE button was pressed. 2. Reset to Factory Default Setup To rest to factory default setup, press the SAVE/RECALL button, then press the DEFAULT SETUP softkey. Page 12 of 12