Motorola HC11 Fun with Microcontrollers. Microcontrollers What is a microcontroller? A processor Usually not cutting edge Dependable All major bugs well.

Slides:



Advertisements
Similar presentations
Instruction Set Design
Advertisements

Microprocessors.
Goal: Write Programs in Assembly
CPU Review and Programming Models CT101 – Computing Systems.
ISA Issues; Performance Considerations. Testing / System Verilog: ECE385.
1 Lecture 3: Instruction Set Architecture ISA types, register usage, memory addressing, endian and alignment, quantitative evaluation.
INSTRUCTION SET ARCHITECTURES
Chapter 2 HARDWARE SUMMARY
Instruction Set Architecture
Processor System Architecture
The 68HC11 Microcontroller Minnesota State University, Mankato
1 Motorola HC-11 Microcontrollers and Embedded Systems.
COMP3221: Microprocessors and Embedded Systems Lecture 2: Instruction Set Architecture (ISA) Lecturer: Hui Wu Session.
TK 2633 Microprocessor & Interfacing Lecture 3: Introduction to 8085 Assembly Language Programming (2) 1 Prepared By: Associate Prof. Dr Masri Ayob.
CS 536 Spring Code generation I Lecture 20.
Fun with Microcontrollers and Embedded Systems
8051 ASSEMBLY LANGUAGE PROGRAMMING
Unit -II CPU Organization By- Mr. S. S. Hire. CPU organization.
EET 2261 Unit 2 HCS12 Architecture
4/6/08Prof. Hilfinger CS164 Lecture 291 Code Generation Lecture 29 (based on slides by R. Bodik)
ARM Core Architecture. Common ARM Cortex Core In the case of ARM-based microcontrollers a company named ARM Holdings designs the core and licenses it.
MIPS Instruction Set Advantages
Rabel Talpur:12BME#025.  40-pin chip  Developed by Motorola in 1975  16 address lines and 8 data lines  Used only +5V.
Lab 1 – Assembly Language and Interfacing Start date: Week 3 Due date: Week 4 1.
Machine Instruction Characteristics
IT253: Computer Organization Lecture 4: Instruction Set Architecture Tonga Institute of Higher Education.
Motorola HC11 Fun with Microcontrollers and Embedded Systems.
Chapter 10 The Assembly Process. What Assemblers Do Translates assembly language into machine code. Assigns addresses to all symbolic labels (variables.
Computer Architecture and Organization
ECE 265 – LECTURE 5 The M68HC11 Basic Instruction Set 12/8/ ECE265.
DIGITAL SIGNAL PROCESSORS. Von Neumann Architecture Computers to be programmed by codes residing in memory. Single Memory to store data and program.
1 ECE 372 – Microcontroller Design Assembly Programming HCS12 Assembly Programming Addressing Modes Stack Operations Subroutines.
MICROOCESSORS AND MICROCONTROLLER:
1 Introduction to Microcontroller Microcontroller Fundamentals & Programming.
What is a program? A sequence of steps
Execution Architecture MTT CPU08 Core M CPU08 INTRODUCTION.
CS61C L20 Datapath © UC Regents 1 Microprocessor James Tan Adapted from D. Patterson’s CS61C Copyright 2000.
ECE 447: Lecture 11 Introduction to Programming in Assembly Language.
1 Basic Processor Architecture. 2 Building Blocks of Processor Systems CPU.
Embedded Systems Lecture 5 January 25 th, 2016.
Subroutines and Stacks. Stack The stack is a special area in memory used by the CPU to store register information or general data information during program.
8085 INTERNAL ARCHITECTURE.  Upon completing this topic, you should be able to: State all the register available in the 8085 microprocessor and explain.
Function Calling. Mips Assembly Call and Return Steps for procedure calling –Save the return address –Jump to the procedure (function) –Execute the procedure.
George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ME 4447/6405 Microprocessor Control of Manufacturing Systems and Introduction.
Lec. 10 Assembly Programming Dr. Tamer Samy Gaafar Microprocessors.
Block diagram of a computer system Basic components of a computer system using block diagrams: Cpu Memory Input and output unit Evolution of microprocessor.
DEPARTMENT OF ELECTRONICS ENGINEERING V-SEMESTER MICROPROCESSOR & MICROCONTROLLER 1 CHAPTER NO microcontroller & programming.
MIPS Instruction Set Advantages
Gunjeet Kaur Dronacharya Group of institutions
Assembly Language Programming of 8085
ECE 3430 – Intro to Microcomputer Systems
Microprocessor T. Y. B. Sc..
Introduction of microprocessor
A Closer Look at Instruction Set Architectures: Expanding Opcodes
Instructions - Type and Format
Chapter 8 Central Processing Unit
Instruction encoding We’ve already seen some important aspects of processor design. A datapath contains an ALU, registers and memory. Programmers and compilers.
Introduction to Microprocessor Programming
Instruction encoding We’ve already seen some important aspects of processor design. A datapath contains an ALU, registers and memory. Programmers and compilers.
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
8051 ASSEMBLY LANGUAGE PROGRAMMING
Where is all the knowledge we lost with information? T. S. Eliot
Lecture 4: Instruction Set Design/Pipelining
COMPUTER ORGANIZATION AND ARCHITECTURE
Register sets The register section/array consists completely of circuitry used to temporarily store data or program codes until they are sent to the.
Computer Operation 6/22/2019.
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
Presentation transcript:

Motorola HC11 Fun with Microcontrollers

Microcontrollers What is a microcontroller? A processor Usually not cutting edge 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 and/or EPROM

What are microcontrollers used in? ? Microcontrollers

Microcontroller unit sales are 15x higher than microprocessors. … and are MUCH cheaper.

Microcontrollers Microcontrollers are a large market 8-bit controllers are the largest

HC11 Motorola 68HC11 M6801 processor ROM (8KB), EEPROM (512B), RAM (256B) Counter/Timer system A/D converter D/A in kit Parallel I/O Expansion bus To add more memory Serial communication

HC11 HC11 Architecture

HC11 CPU Core 8-bit Somewhat CISC Accumulator-based Results wind up in a 8-bit accumulator A (or B) 16-bit results go to accumulator AB, called D. Two index registers for addressing memory or counting: X and Y Dedicated stack pointer Push and Pop instructions use this – grows toward smaller memory addresses like in MAL Program Counter Condition Codes

HC11 CPU

Condition Codes Not present for MIPS integer instructions Single-bit flags set appropriately for most instruction (several instructions do not, including push and pop) C Carry/Borrow V Overflow ZZero NNegative HHalf-Carry MAL codeHC11 codeWhat it does bge $t0, 4, mylabelcmpa #4Subtract AccA - 4, set CCR bge mylabelBranch if (CCR[Z]=1 OR CCR[N]=0)

HC11 CPU Command Register Bits set by the user to tell the processor how to do things IInterrupt Mask XXIRQ mask SDisable STOP instructions

HC11 Instructions HC11 Instructions have variable lengths (not like MAL) Careful coding can keep applications small and able to fit in the EPROM We don’t have to worry about this since we’re using Expansion Mode: there is extra memory in the microkits. The opcode is always 1 byte An additional 0-3 bytes specify the data to work with

HC11 Addressing Addressing Modes MIPS (TAL) has: HC11 has several Check opcode listings to see what modes work with what instructions And what condition codes are set

HC11 Addressing Inherent addressing Opcode fully specifies operation; no addressing Examples: INCB increment accumulator B ASLA Arithmetic Shift Left accumulator A PSHY Push index register Y onto stack

HC11 Addressing Immediate addressing 1 or 2 byte immediate depending on register involved (LDAA vs. LDD) ALWAYS include a # Several formats for different bases -- C-style constants instead of what is in the HC11 manual (don’t use Decimal:LDAA #245 Hexadecimal:LDAA #0x61 Octal: LDAA #041 Binary:LDAA #0b ASCII:LDAA #’a’

HC11 Addressing Direct and enhanced addressing Access an absolute memory location Essentially the same mode, but with 8-bit (direct) or 16-bit (enhanced) addresses The assembler will decide on which to use based on how many bits are needed Example // Your data starts at address 0x4000:.sect.data var:.word0x1000 // Allocate/initialize a word var1:.word0xffff // Note: a word is 16 bits!.sect.text SUBDvar// Subtract [var] from D SUBD0x4000// Subtract [var] from D

HC11 Addressing Indexed addressing Uses index register X or Y Similar to MAL “lw $t0, 4($sp)” But can access memory and use it all at once!! Example #definemydef4// cc preprocessor used ldx#var// Like MAL load address addd0,X// add contents of 0($X) to D // (Note “addd X” doesn’t work) addd2,X// add contents of 2($X) to D adddmydef*2, X// add contents of 8($X) to D

HC11 Addressing Relative addressing Used for branches by the assembler Offsets from –128 to +128 bytes Use jumps for longer branches

HC11 Instructions

HC11 Example /*********************************************************** *Program 1. * A simple program to introduce the 68HC11 environment ***********************************************************/ #include // sets stuff up for you, especially I/O.sect.data SIGNON:.asciz“CMPE12C Simulator” PROMPT:.asciz“>” // (continued…)

HC11 Example Continued /************************************************************* * Your program starts where indicated by the label “main”. After startup * Code in v2_18g3.asm is done, it jumps to this label and continues running. **************************************************************/.sect.text main: ldx#SIGNON jsrOUTSTRING loop:ldx#PROMPT// address of prompt jsrOUTSTRING// write out to serial communications // interface (to PC) jsrGETCHAR// get a character from SCI, returns in A jsrOUTCHAR// write A to the SCI jsrOUTCRLF// write CR/LF to SCI jmploop

Micro Kit Usage Design environment: Edit & assemble on CATS machines > hc11build file.asm Download program to the PC Upload to the microkit using serial cable To use kits at home 9-12V AC adapter Serial download cable Connection to CATS machines Free serial communication software (e.g. TeraTerm)

Micro Kit Usage Always #include as part of your program Sets up memory, including stack pointer Jumps to your “main” label Also includes a basic library of I/O routines Take a look at it! /afs/cats/courses/cmpe12c-rph/include/v2_18g3.asm

Example recursive routine Fibonacci on the switches and LEDs /* Input: A. Returns A’th Fibonacci term in accumulator A */ fib:cmpa#2 bgtfibnot1 ldaa#1// return 1 if n <= 2 rts fibnot1:pshb// caller save protocol deca psha// save n-1 deca// call with n-2 jsrfib tab// transfer F(n-2) to b pula// a gets n-1 jsrfib aba// add accumulators pulb// restore B rts main:ldx#SWITCHES ldaa0,X jsrfib ldx#LEDS staa0,x jmpmain

HC11 Summary Microcontrollers are great little machines for data I/O and data manipulation The CISC-style programming makes ASM programming easier Variable instruction length can be a problem for Word-aligned machines Super-scalar machines Pipelines The RISC philosophy is to Use simple instructions and let the compiler optimize Use loads and stores to support higher-speed registers Neither RISC, its CISC predecessors, nor CISCY RISC has the definitive advantage Depends on application, architecture, and implementation.