Microcontrollers and the Freescale/Motorola HC11

Similar documents
Motorola HC11. Fun with Microcontrollers and Embedded Systems

Microcontrollers and Embedded Systems. Fun with Motorola/Freescale HC11

Microcontrollers. Microcontroller

HC11 Instruction Set

CHAPTER 8. Solutions for Exercises

HC11 Instruction Set Architecture

Exam I Review February 2017

HC11 Instruction Set Architecture

Microcomputer Architecture and Programming

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

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

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

Introduction to the 9S12 Microcontroller


ME 4447/6405. Microprocessor Control of Manufacturing Systems and Introduction to Mechatronics. Instructor: Professor Charles Ume LECTURE 6

Programming the Motorola MC68HC11 Microcontroller

The Motorola 68HC11 Instruc5on Set

Introduction to Microcontrollers

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

Chapter 1. Microprocessor architecture ECE Dr. Mohamed Mahmoud.

ECE 4510/5530 Microcontroller Applications Chapter 1

Wed. Aug 23 Announcements

Mark II Aiken Relay Calculator

Disassembly of MC9S12 op codes Decimal, Hexadecimal and Binary Numbers

Disassembly of MC9S12 op codes Decimal, Hexadecimal and Binary Numbers

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

The Microcontroller. Lecture Set 3. Major Microcontroller Families. Example Microcontroller Families Cont. Example Microcontroller Families

8051 Overview and Instruction Set

COSC345 Software Engineering. Basic Computer Architecture and The Stack

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

Design of Embedded Systems Using 68HC12/11 Microcontrollers

MC9S12 Address Space

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

DEPARTMENT OF ECE QUESTION BANK SUBJECT: MICROPROCESSOR AND MICROCONTROLLER UNIT-1 PART-A (2 MARKS)

Chapter 7 Central Processor Unit (S08CPUV2)

ECE 372 Microcontroller Design Basic Assembly Programming. ECE 372 Microcontroller Design Basic Assembly Programming

Lecture 9 Subroutines

EE 308: Microcontrollers

ECE331 Handout 3- ASM Instructions, Address Modes and Directives

Introduction to Microcontrollers III

EE 3170 Microcontroller Applications

538 Lecture Notes Week 5

538 Lecture Notes Week 5

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

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

Microprocessors/Microcontrollers

Accumulator and memory instructions 1. Loads, stores, and transfers 2. Arithmetic operations 3. Multiply and divide 4. Logical operations 5. Data test

Sample Problem Set #1

ECED3204: Microprocessor Part I--Introduction

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

SYLLABUS UNIT - I 8086/8088 ARCHITECTURE AND INSTRUCTION SET

Introduction to Microcontrollers III

S12CPUV2. Reference Manual HCS12. Microcontrollers. S12CPUV2/D Rev. 0 7/2003 MOTOROLA.COM/SEMICONDUCTORS

538 Lecture Notes Week 3

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

Coe538 Final Study Guide 2016 (Questions & Answers)

CHAPTER ASSEMBLY LANGUAGE PROGRAMMING

Outline. 2.8 Stack. 2.9 Subroutines

Fredrick M. Cady. Assembly and С Programming forthefreescalehcs12 Microcontroller. шт.

BASIC INTERFACING CONCEPTS

Introduction to Computers - Chapter 4

Introduction to general architectures of 8 and 16 bit micro-processor and micro-controllers

CDA 3103 Computer Organization Homework #7 Solution Set

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

Cmpt 150 The Freescale CPU12 March, The Freescale HC12

Getting Started with the HCS12 IDE

FIFTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLOGY-MARCH 2014 EMBEDDED SYSTEMS (Common for CT,CM) [Time: 3 hours] (Maximum marks : 100)

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

Lab 7: Asynchronous Serial I/O

Computers and Microprocessors

Summer 2003 Lecture 1 06/09/03

EE 42/100 Lecture 25: Binary Signals / Microcontrollers. Rev C 4/26/2012 (9:07 AM) Prof. Ali M. Niknejad

Cross Assembly and Program Development

538 Lecture Notes Week 1

8051 Microcontrollers

EMBEDDED SYSTEMS INTRODUCTION

Linking Assembly Subroutine with a C Program

Mechatronics and Microcomputers. Stipendium Hungaricum 2018/2019 Autumn Semester Szilárd Aradi, PhD

V8-uRISC 8-bit RISC Microprocessor AllianceCORE Facts Core Specifics VAutomation, Inc. Supported Devices/Resources Remaining I/O CLBs

PIC Microcontroller and

SECTION 6 CENTRAL PROCESSING UNIT

8051 microcontrollers

Introduction to Programming

The HC11. Alexandra Carey & Richard Hughey. University of California, School of Engineering Santa Cruz, CA 95064

instruction 1 Fri Oct 13 13:05:

CPU12 REFERENCE MANUAL

Question Bank Microprocessor and Microcontroller

Computer Hardware Requirements for ERTSs: Microprocessors & Microcontrollers

Digital Blocks Semiconductor IP

Unit wise Question Bank UNIT-II

EKT222 Miroprocessor Systems Lab 5

MICROCONTROLLER AND PLC LAB-436 SEMESTER-5

ME 6405 Introduction to Mechatronics

Using the stack and the stack pointer

Chapter 4: Advanced Assembly Programming. EE383: Introduction to Embedded Systems University of Kentucky. Samir Rawashdeh

Exam 2 E2-1 Fall Name: Exam 2

CPU08RM/AD REV 3 8M68HC08M. CPU08 Central Processor Unit. Reference Manual

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

CN310 Microprocessor Systems Design

Architecture & Instruction set of 8085 Microprocessor and 8051 Micro Controller

Transcription:

Microcontrollers and the Freescale/Motorola HC11

What is a microcontroller? A computer on a chip used to control electronic devices A microprocessor Usually not cutting edge (4-bit to 32-bit) Dependable (all major bugs well known) Predictable (critical for real-time processing) On-chip peripherals and memory Parallel and serial digital I/O Analog I/O Counters and timers Internal ROM, RAM and/or EPROM CMPE12 Summer 2009 15-2

What are microcontrollers used in? Microcontrollers are used in Watches Microwaves Stereo Receivers ATMs PDAs, MP3 players Automobiles (between 9 and 50) Some products that you might know: NASA s Sojourner Rover 8-bit Intel 80C85 Palm Vx handheld 32-bit Motorola Dragonball EZ Sonicare toothbrush 8-bit Zilog Z8 The Vendo V-MAX 720 Soda Machine Motorola HC11 Miele dishwasher 8-bit Motorola 68HC05 Hunter 44550 Programmable Thermostat (4-bit cpu) CMPE12 Summer 2009 15-3

Microprocessor unit sales Microprocessor unit sales are 100 times higher than microcontroller sales Microprocessor: 220 million Microcontroller: 20 billion Microcontrollers are much, much cheaper 55% of CPUs sold are 8- bit microcontrollers and microprocessors CMPE12 Summer 2009 15-4

Languages for microcontrollers Language 98-99 99-00 Assembly ~ 21% ~ 10% C ~ 69% ~ 80% C++ ~ 5% ~ 6% Java ~ 1 % ~ 2% Other ~ 3 % ~ 2% Source: TRON Association Survey 1998/99 & 1999/2000 CMPE12 Summer 2009 15-9

Motorola / Freescale MC68HC11A8 M6801 CPU core Memory: 8KB ROM 512B EEPROM 256B RAM Counter/Timer system 8-channel, 8-bit A/D converter Analog to digital converter (external D/A in our kit) Parallel I/O port Two serial I/O ports: Asynchronous, SCI Synchronous, SPI Expansion bus for external memory CMPE12 Summer 2009 15-10

What are RAM and ROM? RAM: Random-access memory Write to any location with the same effort (Same amount of time) ROM: (Random-access) read-only memory PROM: Programmable ROM EPROM: Erasable PROM Erasable with UV light Phased out since about 1998 EEPROM: Electrically-erasable PROM Flash EEPROM: Faster EEPROM CMPE12 Summer 2009 15-11

High-level HC11 architecture Interrupt logic MEMORY Timer and counter M8601 CPU core Serial I/O A/D converter Port A Port B Port C Port D Port E CMPE12 Summer 2009 15-12

Our HC11 microkit LCD display brightness control LCD Serial cable to PC AC/DC Power adapter LEDs HC11 µc Switches CMPE12 Summer 2009 15-13

Our HC11 microkit board Serial (RS232C) connector LCD display brightness control HC11 µc External RAM HW Reset EEPROM LEDs Interrupt Switches CMPE12 Summer 2009 15-14

HC11 programmer-accessible hardware Buttons Reset Interrupt (IRQ) Switches 8 switches, MSb on far left and LSb on far right Accessed by reading from SWITCHES LEDs 8 LEDs, MSb on far left and LSb on far right Accessed by writing to LEDS Active low (writing a 0 turns a light on) LCD Two lines, 16 characters per line We provide some routines output to LCD CMPE12 Summer 2009 15-16

The HC11 instruction set architecture Mixed 8-bit/16-bit architecture CISC, with more than 100 opcodes One instruction can use several addressing modes, depending on how you use it Accumulator architecture CMPE12 Summer 2009 15-17

An aside: accumulator architecture One operand comes from memory The other comes from the accumulator CMPE12 Summer 2009 15-18

The HC11 accumulators and registers Two 8-bit accumulators, or you can use them together as one 16-bit accumulator Two 8-bit accumulators, A or B One 16-bit accumulator [A:B], called D Two index registers Two 16-bit index registers, X and Y, used for addressing memory or for counting Special registers 16-bit dedicated stack pointer, SP 16-bit program counter, PC 8-bit condition codes register, CCR CMPE12 Summer 2009 15-19

The HC11 registers CMPE12 Summer 2009 15-20

Accumulators: A, B, and D General-purpose 8-bit accumulators Source/destination of most operations Almost always interchangeable E.g., ABA, add B to A A (A + B) B is unchanged Note that there is no AAB instruction SBA, subtract B from A A (A B) Note that there is no SAB instruction 7 A 0 7 B 0 15 D 0 CMPE12 Summer 2009 15-21

Accumulators: A, B, and D Some instructions use [A:B] as a single 16-bit register D E.g. ADDD #2 LDD #1 MUL 7 A 0 7 B 0 15 D 0 CMPE12 Summer 2009 15-22

Index registers X and Y 15 X 0 15 Y 0 16-bit index registers X and Y: Used for indexed addressing mode Swap with register D to perform complex address operations Address space: 64KB LC-3: 64K words, which is 128 KB CMPE12 Summer 2009 15-23

HC11 User Stack The HC11 has a stack set up at start-up Memory is byte-addressable PSHA PSHY PULA PULY // push accumulator A onto stack // SP = SP 1 since a byte size // push index register Y onto stack // SP = SP 2 since a word size // Pop off a byte from the stack into A // SP = SP + 1 // Pop off a word from the stack into Y // SP = SP + 2 CMPE12 Summer 2009 15-24

An aside: the RPN calculator RPN is Reverse Polish Notation HP calculators E.g., A = CD+E Push C Push D Mult Push E Add Pop A DE CD+E CCD A TOP CMPE12 Summer 2009 15-25

Stack pointer: SP 16-bit stack pointer, SP Automatically incremented or decremented on pushes and pops Can be used for data and return addresses Return address for subroutines is automatically pushed with jsr and popped with rts 15 SP 0 CMPE12 Summer 2009 15-26

Program counter: PC 16-bit program counter, PC 15 PC 0 CMPE12 Summer 2009 15-27

Condition code register: CCR Five status indicators H, half carry (used only for BCD operations) N, negative Z, zero S X H I N Z V C V, overflow (two s complement) C, carry/borrow many instructions set them all, but not all instructions Two interrupt masking bits I, disable all maskable interrupts (1 = disable) X, disable external interrupts (1 = disable) A STOP-disable bit disables the STOP instruction CMPE12 Summer 2009 15-28

Programming on the HC11 microkit Design environment: Edit the source file Assemble on UNIX machine > hc11build file.asm Will produce an object (executable) file called file.s19 Download program to the PC with terminal program TeraTerm Upload to the microkit using serial cable To use kits at home Get one at BELS Have a connection to ITS machines Get TeraTerm, which is free Or any program which is capable of serial communication CMPE12 Summer 2009 15-29

Programming on the HC11 microkit As part of your program, always have #include <v2_18g3.asm> What the include file does Sets up memory, including the stack pointer Jumps to the main label Includes a basic library of I/O routines CMPE12 Summer 2009 15-30

Structure of a source program /* header comments */ #include <v2_18g3.asm>.sect.data // your variables here.sect.text // your code here main: // must have a main: function CMPE12 Summer 2009 15-31

Example program echo.asm #include <v2_18g3.asm>.sect.data signon:.asciz "CMPE12C Welcome!" prompt:.asciz ">".sect.text main: ldx #signon jsr OUTSTRING // write a null-terminated // string to serial port echo_loop: ldx #prompt // address of prompt jsr OUTSTRING // write out to serial port jsr GETCHAR // getchar returns in ACCA jsr OUTCHAR // write ACCA to screen jsr OUTCRLF // write '\n' to serial port jmp echo_loop CMPE12 Summer 2009 15-32

Example program factorial The factorial function x! = x (x-1) (x-2) 3 2 1 Two ways to do it Recursively Non-recursively Draw a flow chart Write an algorithm CMPE12 Summer 2009 15-33

Example program factorial.asm (1/2) 1 #include <v2_18g3.asm> 2 3.sect.data 4 5 welcome:.asciz " Factorial!" 6 7 prompt:.asciz "Fact is " blanks:.asciz " " 8 9 input:.byte 0 10.sect.text 11 12 main: ldx #welcome 13 ldaa #1 // line 1 14 jsr LCDSTRING // write to LCD, expects in X 15 ldx #blanks 16 inca // line 2 17 jsr LCDSTRING // write to LCD 18 ldx #prompt 19 jsr LCDSTRING // write to LCD CMPE12 Summer 2009 15-34

Example program factorial.asm (2/2) 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 ldab SWITCHES // B SWITCHES jsr fact_start jsr LCDINT // expects input in D stab LEDS // LEDS B always: jmp always // factorial: assume input in B, output in D fact_start: stab input // input B tba // A B fact: dec input // input (input 1) ldaa input // A input beq fact_done // Z? mul // D (A B) jmp fact fact_done: rts CMPE12 Summer 2009 15-35

Compiling the program CMPE12 Summer 2009 15-41

CMPE12 Summer 2009 15-42

Downloading the program Just drag & drop CMPE12 Summer 2009 15-43

Running the program Note the LEDs: is the number correct? CMPE12 Summer 2009 15-44

Recommended exercises Write and run the Fibonacci program. CMPE12 Summer 2009 15-45