Introduction to Microcontrollers III

Similar documents
Introduction to Microcontrollers III

Introduction to Microcontrollers

ECE 3610 MICROPROCESSING SYSTEMS

Introduction to Microcontrollers II

Introduction to Microcontrollers II

Using the stack and the stack pointer

Exam I Review February 2017

Coe538 Final Study Guide 2016 (Questions & Answers)

ECE 331: PC Lab 3 Stack and Subroutines

1. Memory Mapped Systems 2. Adding Unsigned Numbers

Cross Assembly and Program Development

Computer Organization I. Lecture 28: Architecture of M68HC11

Homework 3 Aid Understanding Homework 2/3 Program

Programming the Motorola MC68HC11 Microcontroller

What is an Addressing Mode?

2. Arithmetic Instructions addition, subtraction, multiplication, divison (HCS12 Core Users Guide, Sections 4.3.4, and ).

MC9S12 Assembler Directives A Summary of MC9S12 Instructions Disassembly of MC9S12 op codes. Summary of HCS12 addressing modes ADDRESSING MODES

ECE 367 -Experiment #1 Fall 2012

ECE331 Handout 3- ASM Instructions, Address Modes and Directives

Microcontrollers and the Freescale/Motorola HC11

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

Disassembly of MC9S12 op codes Decimal, Hexadecimal and Binary Numbers

Disassembly of MC9S12 op codes Decimal, Hexadecimal and Binary Numbers

Chapter 2: HCS12 Assembly Programming. EE383: Introduction to Embedded Systems University of Kentucky. Samir Rawashdeh

Table 1: Mnemonics Operations Dictionary. Add Accumulators Add B to Y. Add with carry to B. Add Memory to B. Add 16-bit to D And B with Memory

The Motorola 68HC11 Instruc5on Set

Lab 2 Part 1 Assembly Language Programming and 9S12 Ports

Lecture 9 Subroutines

Microcontrollers. Microcontroller

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

CMPEN 472 Sample EXAM II

538 Lecture Notes Week 5

HC 11 Instructions! From Alex Hollowayʼs notes with! many thanks!

538 Lecture Notes Week 5

Lab 8: Debugging Embedded Devices and Software

AN1239. HC05 MCU Keypad Decoding Techniques Using the MC68HC705J1A. Introduction

ASSIGNMENT 3: PLAYING WITH THE 68HC11. Due Wednesday, Oct 9, 2002

Application Note. Interfacing the CS5525/6/9 to the 68HC05. By Keith Coffey MOSI (PD3) SDO MISO (PD2) SCLK. Figure 1. 3-Wire and 4-Wire Interfaces

0b) [2] Can you name 2 people form technical support services (stockroom)?

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

Menu Computer Organization Programming Model for the an example microprocessors (the G-CPU & Motorola 68HC11) Assembly Programming Look into my...

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

538 Lecture Notes Week 1

68HC11 Opera,ng Modes

CPU Temperature Regulation

ASSIGNMENT 4: INTRODUCTION TO THE 68HC11. Out: Monday, Sep 29, 2003 Due Monday, Oct 6, 2003

COSC 243. Instruction Sets And Addressing Modes. Lecture 7&8 Instruction Sets and Addressing Modes. COSC 243 (Computer Architecture)

COE538 Lecture Notes Week 3 (Week of Sept 17, 2012)

Example Programs for 6502 Microprocessor Kit

UNIVERSITY OF MANITOBA DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING. Term Test #2 Solution ECE 3610 MICROPROCESSING SYSTEMS

Computer Architecture Programming the Basic Computer

Introduction to Mechatronics. Fall Instructor: Professor Charles Ume. Interrupts and Resets

Reading Assignment. 68HC12 Instruction Set. M68HC12 Instruction Set Categories. Some Tips. Endianness (Byte Order) Load and Store Instructions

Laboratory Exercise 4

Introduction to Programming

Homework 12 Solutions

Lecture 6 Assembly Programming: Branch & Iteration

2) [ 2 marks] Both of the following statements cause the value $0300 to be stored in location $1000, but at different times. Explain the difference.

C SC 230 Computer Architecture and Assembly Language April 2000 Exam Sample Solutions

COSC345 Software Engineering. Basic Computer Architecture and The Stack

Programming Book for 6809 Microprocessor Kit

LECTURE #21: G-CPU & Assembly Code EEL 3701: Digital Logic and Computer Systems Based on lecture notes by Dr. Eric M. Schwartz

HC11 Instruction Set

Sample Problem Set #1

538 Lecture Notes Week 2

MIGRATING TO THE 68HC12 IN C

SECTION 6 CENTRAL PROCESSING UNIT

instruction 1 Fri Oct 13 13:05:

Motorola HC11. Fun with Microcontrollers and Embedded Systems

Application Note. Interfacing the CS5521/22/23/24/28 to the 68HC05. Figure 1. 3-Wire and 4-Wire Interfaces

Microcontrollers. 2IN60: Real-time Architectures (for automotive systems) Mike Holenderski,

; export symbols ; export 'Entry' symbol. ; include derivative specific macros PORTA EQU $0000 PORTB EQU $0001 DDRA EQU $0002 DDRB EQU $0003

EMCH 367 Fundamentals of Microcontrollers Example_RPM_2 EXAMPLE RPM_2

CREATING LOOP-BASED TIME DELAYS IN MICROPROCESSOR SYSTEMS

TEMPERATURE SENSOR. Revision Class. Instructor / Professor LICENSE

Chapter Family Microcontrollers Instruction Set

Subroutines and the Stack

Capstone Design Course. Lecture-2: The Timer

Module 1-D. Control Structure Applications. Tim Rogers 2017 [1.D]-1

Immediate vs. Extended mode: Immediate values are marked with a # symbol. They also are different instructions when assembled.

Introduction to Microcontroller. Systems. Embedded system. Assembler or C? Datatypes 2. Datatypes 1

EMCH 367 Fundamentals of Microcontrollers Example_Sort EXAMPLE SORT

Lab 7: Asynchronous Serial I/O

CET335 Microprocessor Interfacing Lab 5: LCD Interface (Bus Attached Peripheral)

8051 Overview and Instruction Set

Microcomputer Architecture and Programming

Timing Generation and Measurements

Outline. 2.8 Stack. 2.9 Subroutines

Lecture #4 Microcontroller Instruction Set Embedded System Engineering Philip Koopman Monday, 25-Jan-2016

E.E Electrical Engineering Design

EE 308 Spring A software delay. To enter a software delay, put in a nested loop, just like in assembly.

COMPUTE! ISSUE 36 / MAY 1983 / PAGE 244

Chapter 5 Sections 1 6 Dr. Iyad Jafar

Input/Output Modes Chapter 8

ECE L A B 1 Introduction ASSEMBLY PROGRAMMING WITH MINIIDE

Introduction to Computers - Chapter 4

EE 308 LAB 1 ASSEMBLER, SIMULATOR, AND MONITOR. Introduction and Objectives

Getting Started with the HCS12 IDE

POTENTIOMETER. Revision Class. Instructor / Professor LICENSE

ME 6405 Introduction to Mechatronics

Transcription:

Introduction to Microcontrollers III Timing Functions Delay5u.a11, Delay1m.a11 µp Laboratory #3

Data Entry : µp Laboratory #2 Hints Use the pushbutton routine from count.a11 or count_br.a11 (WAIT0 and WAIT1 loops) Consider using Indexed addressing for entering data loops Store numbers to $D000-$D007 Display numbers to output PortB ($1004)

µp Laboratory #2 Hints Data Sum : Assume number located at $D000-$D007 Consider using Indexed addressing for accessing each memory location Use AccA or AccB for temporary storage of sum

µp Laboratory #2 Hints Data Sum : Assume number located at $D000-$D007 Need two loops for sorting Consider using Indexed addressing for your loops

Sort Routine Initialize counters Compare contents of location i with i+1 If contents of i is less than contents of i+1, swap; otherwise increment counter If inner loop is done increment outer loop counter If outer loop is done, end; otherwise reset inner loop counter and begin again

Swap Routine AccA AccB $08 IndexX $D000 Counter i = $D000 D000 D001 D002 D003 D004 D005 D006 D007

Swap Routine ldaa 0,x AccA AccB $08 IndexX $D000 Counter i = $D000 D000 D001 D002 D003 D004 D005 D006 D007

Swap Routine ldaa 1,x AccA AccB $08 $08 IndexX $D000 Counter i = $D000 D000 D001 D002 D003 D004 D005 D006 D007

Swap Routine Compare AccB to AccA AccA AccB $08 $08 IndexX $D000 Counter i = $D000 D000 D001 D002 D003 D004 D005 D006 D007

Swap Routine staa 1,x AccA AccB $08 IndexX $D000 Counter i = $D000 D000 D001 D002 D003 D004 D005 D006 D007

Swap Routine stab 0,x AccA AccB $08 $08 IndexX $D000 Counter i = $D000 Then, increment IndexX D000 D001 D002 D003 D004 D005 D006 D007

What about timing functions? Sometimes you want to put a delay in your program.the HC11 has advanced features that use a real-time clock. Refer to chapter 10 of the HC11 Reference Manual for information on usage. An alternative is the use of delay subroutines: delay5u.a11 and delay1m.a11

Timer Application 1: delay5u.a11 Delay = X * 5 µs Load X with the number of times you want to delay for 5 µs. ************************************************ * DELAY5U.A11 * AUTHORS DATE COMMENTS * JACOBSON/SEVCIK 2/26/90 VERSION 1.0 * * DESCRIPTION * THIS ROUTINE GENERATES INTERNAL DELAYS IN * MULTIPLES OF FIVE (5) MICRO-SECONDS. THE * USER ENTERS A MULTIPLIER (16-BIT) INTO THE * X INDEX REGISTER WHICH DETERMINES THE NUMBER * OF FIVE MICRO-SECOND INTERVALS * * PARAMETERS * - X REGISTER CONTAINS MULTIPLIER * - INTERRUPTS ARE NOT AFFECTED * - SHORTEST DELAY IS 10 us (X < 3) * - RESOLUTION IS 5 us * - MAXIMUM DELAY IS 327680 us (X = 64K) ***********************************************

ORG $COOO ldx #1000 ;FOR TESTING JSR DELAY5U ;CALL ROUTINE TO TEST JMP $E00A ;JUMP TO BUFFALO WHEN DONE DELAY5U: DEX ;CORRECT FOR JSR/RTS DEX ;OVERHEAD NOP NOP DELWT1: DEX ;DECREMENT MULTIPLIER NOP NOP BNE DELWT1 RTS *********************************************** * END DELAY5U *********************************************** This program uses the JSR instruction to call the subroutine: DELAY5U. The actual subroutine consists of loops of instructions that just take up computer time.

Timer Application 2: delay1m.a11 Delay = X * 1 ms Load X with the number of times you want to delay for 1 ms. ************************************************ * DELAY1M.A11 N*1ms Delay Routine * AUTHORS DATE COMMENTS * JACOBSON/SEVCIK 2/26/90 VERSION 1.0 * * DESCRIPTION * THIS ROUTINE GENERATES INTERNAL DELAYS IN * MULTIPLES OF ONE (1) MILLI-SECOND. THE * USER ENTERS THE DURATION OF THE DELAY * (ms) INTO THE X REGISTER * * PARAMETERS * - X REGISTER CONTAINS DURATION (ms) * - INTERRUPTS ARE NOT AFFECTED * - SHORTEST DELAY IS 1 ms (X =1) * - RESOLUTION IS 1 ms * - MAXIMUM DELAY IS 655,36 ms (X = 0) ************************************************* ** *

TEST ROUTINE * user must enter a value into X, then run ORG $COOO * change operand of next instruction to change * the delay TEST ldx #100 ;FOR 100 ms DELAY JSR DELAY1M ;CALL ROUTINE TO TEST JMP $E00A ;JUMP TO BUFFALO WHEN DONE ************************************************** * DELAY1M N*1ms subroutine ************************************************** DELAY1M:PSHA * Primary Loop DELWT2 LDAA #199 ;199 * 2ND LOOP = 1ms NOP DELWT3 DECA ;SECONDARY LOOP = 1ms/199 NOP BRN DELWT3 ;BRANCH NEVER = 3 CYCLE NOP BNE DELWT3 ;CONTINUE UNTIL 199 --> 0 This program uses the JSR instruction to call the subroutine: DELAY1M. The actual subroutine consists of 2 loops of instructions that just take up computer time. Notice: PSHA, PULA DEX ;# OF 1ms LOOPS BNE DELWT2 ;CONTINUE UNTIL IX = 0 PULA RTS *********************************************** * END DELAY1M ***********************************************

Laboratory µp3: Count-down Timer Pre-lab: Design a circuit using the HC11EVB that will meet the following specs: 1. A two-digit BCD number will be entered. 2. Display the number on 7 segment displays as it counts down to zero @ 1.00Hz 3. Make an audible noise for the last 1 second before reaching zero. 4. When the number reaches zero, drive a relay closed (Output an active high signal) 5. Use the HC11EVb as the primary controller. 6. Use a minimum number of extra Ics 7. The two-digit bumber will be entered using an 8-position dip switch of two BCD switches. Pre-compile all source code. Bring source code listings (on paper) and floppy disk containing the files to lab. The files should be error free at the beginning of the lab period. Include flow charts for your source code.