Microcontrollers and the Freescale/Motorola HC11



Similar documents
Microcontroller Basics A microcontroller is a small, low-cost computer-on-a-chip which usually includes:

Introduction to Microcontrollers

MICROPROCESSOR AND MICROCOMPUTER BASICS

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Question Bank Subject Name: EC Microprocessor & Microcontroller Year/Sem : II/IV

2.0 Command and Data Handling Subsystem

LSN 2 Computer Processors

MACHINE ARCHITECTURE & LANGUAGE

Chapter 13. PIC Family Microcontroller

Microprocessor and Microcontroller Architecture

8051 MICROCONTROLLER COURSE

Microprocessor or Microcontroller?

HC12 Assembly Language Programming

Microprocessor & Assembly Language

ADVANCED PROCESSOR ARCHITECTURES AND MEMORY ORGANISATION Lesson-17: Memory organisation, and types of memory

The stack and the stack pointer

Embedded Software Development: Spottbillige Hardware + OSS = Zum Spielen zu Schade!

M6800. Assembly Language Programming

Microcontrollers A Brief History of Microprocessors

MICROPROCESSOR BCA IV Sem MULTIPLE CHOICE QUESTIONS

CHAPTER 7: The CPU and Memory

Von der Hardware zur Software in FPGAs mit Embedded Prozessoren. Alexander Hahn Senior Field Application Engineer Lattice Semiconductor

MICROPROCESSOR. Exclusive for IACE Students iacehyd.blogspot.in Ph: /422 Page 1

Central Processing Unit (CPU)

DS1104 R&D Controller Board

Lab Experiment 1: The LPC 2148 Education Board

Microcontrollers in Practice

Advanced Computer Architecture-CS501. Computer Systems Design and Architecture 2.1, 2.2, 3.2

SKP16C62P Tutorial 1 Software Development Process using HEW. Renesas Technology America Inc.

PART B QUESTIONS AND ANSWERS UNIT I

Programming Flash Microcontrollers through the Controller Area Network (CAN) Interface

İSTANBUL AYDIN UNIVERSITY

Block 3 Size 0 KB 0 KB 16KB 32KB. Start Address N/A N/A F4000H F0000H. Start Address FA000H F8000H F8000H F8000H. Block 2 Size 8KB 16KB 16KB 16KB

CHAPTER 4 MARIE: An Introduction to a Simple Computer

Freescale Semiconductor, I

Chapter 2 Logic Gates and Introduction to Computer Architecture

Logical Operations. Control Unit. Contents. Arithmetic Operations. Objectives. The Central Processing Unit: Arithmetic / Logic Unit.

Lecture 3 Addressing Modes, Instruction Samples, Machine Code, Instruction Execution Cycle

a storage location directly on the CPU, used for temporary storage of small amounts of data during processing.

1 Classical Universal Computer 3

The Programming Interface

8051 hardware summary

Soft processors for microcontroller programming education

A+ Guide to Managing and Maintaining Your PC, 7e. Chapter 1 Introducing Hardware

Byte code Interpreter for 8051 Microcontroller

Digitale Signalverarbeitung mit FPGA (DSF) Soft Core Prozessor NIOS II Stand Mai Jens Onno Krah

Freescale Semiconductor, Inc. Product Brief Integrated Portable System Processor DragonBall ΤΜ

Monitoring of Intravenous Drip Rate

A3 Computer Architecture

The Central Processing Unit:

How It All Works. Other M68000 Updates. Basic Control Signals. Basic Control Signals

Tutorial for MPLAB Starter Kit for PIC18F

7a. System-on-chip design and prototyping platforms

Quick Start Tutorial. Using the TASKING* Software Development Tools with the Intel 8x930 Family Evaluation Board

Introduction to Microcontrollers

EMBEDDED SYSTEM BASICS AND APPLICATION

CHAPTER 6: Computer System Organisation 1. The Computer System's Primary Functions

An Overview of Stack Architecture and the PSC 1000 Microprocessor

Instruction Set Design

The goal is to program the PLC and HMI to count with the following behaviors:

Modbus RTU Communications RX/WX and MRX/MWX

Computer Architecture Lecture 3: ISA Tradeoffs. Prof. Onur Mutlu Carnegie Mellon University Spring 2013, 1/18/2013

ECIO40P ECIO28P ECRM40. Page 1. USB programmable microcontrollers. 0.6 DIP footprint. Supplied with a free version of Flowcode. E-blocks compatible

8-Bit Flash Microcontroller for Smart Cards. AT89SCXXXXA Summary. Features. Description. Complete datasheet available under NDA

An Introduction to the ARM 7 Architecture

OVERVIEW OF MICROPROCESSORS

CSC 2405: Computer Systems II

Computer and Set of Robots

Software engineering for real-time systems

Evolution of 8-bit Microcontrollers

Programmer s Model = model of µc useful to view hardware during execution of software instructions

The I2C Bus. NXP Semiconductors: UM10204 I2C-bus specification and user manual HAW - Arduino 1

An Introduction to MPLAB Integrated Development Environment

Management Challenge. Managing Hardware Assets. Central Processing Unit. What is a Computer System?

Controlling a Dot Matrix LED Display with a Microcontroller

Timer A (0 and 1) and PWM EE3376

Introduction the Serial Communications Huang Sections 9.2, 10.2 SCI Block User Guide SPI Block User Guide

Microcontrollers Figure 26-1 Objectives Key Words and Terms 26.1 OVERVIEW OF THE MICROCONTROLLER microcontroller

ENGI E1112 Departmental Project Report: Computer Science/Computer Engineering

Instruction Set Architecture. or How to talk to computers if you aren t in Star Trek

AUTOMATIC NIGHT LAMP WITH MORNING ALARM USING MICROPROCESSOR

Atmel s Self-Programming Flash Microcontrollers

Interrupts and the Timer Overflow Interrupts Huang Sections What Happens When You Reset the HCS12?

Z80 Instruction Set. Z80 Assembly Language

what operations can it perform? how does it perform them? on what kind of data? where are instructions and data stored?

C8051F020 Utilization in an Embedded Digital Design Project Course. Daren R. Wilcox Southern Polytechnic State University Marietta, Georgia

Here is a diagram of a simple computer system: (this diagram will be the one needed for exams) CPU. cache

DsPIC HOW-TO GUIDE Creating & Debugging a Project in MPLAB

(Refer Slide Time: 00:01:16 min)

RISC AND CISC. Computer Architecture. Farhat Masood BE Electrical (NUST) COLLEGE OF ELECTRICAL AND MECHANICAL ENGINEERING

Palaparthi.Jagadeesh Chand. Associate Professor in ECE Department, Nimra Institute of Science & Technology, Vijayawada, A.P.

Microtronics technologies Mobile:

CPU Organization and Assembly Language

Microprocessor/Microcontroller. Introduction

Advanced Microcontrollers Grzegorz Budzyń Lecture. 3: Electrical parameters of microcontrollers 8051 family

Use of Simulator in Teaching Introductory Computer Engineering*

8051 Flash Microcontroller. Application Note. A Digital Thermometer Using the Atmel AT89LP2052 Microcontroller

M68EVB908QL4 Development Board for Motorola MC68HC908QL4

ET-BASE AVR ATmega64/128

Computer Automation Techniques. Arthur Carroll

Lab 1 Course Guideline and Review

Transcription:

Microcontrollers and the Freescale/Motorola HC11 Summer 2008 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 2008 Slides by ADB 2 1

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 2008 Slides by ADB 3 Microprocessor unit sales are 100 times higher than microcontroller sales Microprocessor: 220 million Microcontroller: 20 billion Microcontrollers are much, much cheaper Microprocessor unit sales CMPE12 Summer 2008 Slides by ADB 4 2

Microcontrollers (1/4) AMCC Until May 2004, these µcs were developed and marketed by IBM, whose 4xx family was sold to Applied Micro Circuits Corporation. 403 PowerPC CPU PPC 403GCX 405 PowerPC CPU PPC 405EP PPC 405GP/CR PPC 405GPr PPC NPe405H/L 440 PowerPC Book-E CPU PPC 440GP PPC 440GX PPC 440EP/EPx/GRx PPC 440SP/SPe Altera Nios II 32-bit configurable soft processor Nios 16-bit configurable soft processor Atmel AT89 series (Intel 8051 architecture) AT90, ATtiny, ATMega series (AVR architecture) (Atmel Norway design) AT91SAM (ARM architecture) AVR32 (32-bit AVR architecture) Charmed Labs Cypress MicroSystems Dallas Semiconductor CMPE12 Summer 2008 Slides by ADB 5 Microcontrollers (2/4) Freescale Semiconductor Until 2004, these µcs were developed and marketed by Motorola, whose semiconductor division was spun-off to establish Freescale. 8-bit 68HC05 (CPU05) 68HC08 (CPU08) 68HC11 (CPU11) 16-bit 68HC12 (CPU12) 68HC16 (CPU16) Freescale DSP56800 (DSPcontroller) 32-bit Freescale 683XX MPC500 MPC 860 (PowerQUICC) MPC 8240/8250 (PowerQUICC II) MPC 8540/8555/8560 (PowerQUICC III) Fujitsu Holtek Infineon 8-bit XC800 family C500/C800 family 16-bit XC166 family 32-bit family TRICORE family CMPE12 Summer 2008 Slides by ADB 6 3

Intel 8-bit Microcontrollers (3/4) MCS-48 (8048 family also incl. 8035, 8038, 8039, 8040, 8X42, 8X49, 8050; X=0 or 7) MCS-51 (8051 family also incl. 8X31, 8X32, 8X52; X=0, 3, or 7) 8xC251 16-bit MCS-96 (8096 family also incl. 8061) Intel MCS 296 Lattice Semiconductor Mico8 softcore 8 bit microcontroller Microchip Technology 8 and 16-bit microcontrollers with 12 to 24-bit instructions ability to include DSP function 12-bit instruction PIC 14-bit instruction PIC PIC16F84 16-bit instruction PIC National Semiconductor COP8 CR16 NEC Philips Semiconductors Rabbit Semiconductor CMPE12 Summer 2008 Slides by ADB 7 Microcontrollers (4/4) Renesas Technology (Renesas is a joint venture of Hitachi and Mitsubishi Electric.) Silabs Silicon Motion STMicroelectronics Texas Instruments Toshiba Western Design Center Ubicom Xemics Xilinx ZiLOG CMPE12 Summer 2008 Slides by ADB 8 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 2008 Slides by ADB 9 M6801 CPU core Memory: Motorola / Freescale MC68HC11A8 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 2008 Slides by ADB 10 5

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 EEPROM: Electrically-erasable PROM Flash EEPROM: Faster EEPROM CMPE12 Summer 2008 Slides by ADB 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 2008 Slides by ADB 12 6

Our HC11 microkit LCD display brightness control LCD Serial cable to PC AC/DC Power adapter LEDs HC11 µc Switches CMPE12 Summer 2008 Slides by ADB 13 Serial (RS232C) connector Our HC11 microkit board LCD display brightness control HC11 µc External RAM HW Reset EEPROM LEDs Interrupt Switches CMPE12 Summer 2008 Slides by ADB 14 7

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 2008 Slides by ADB 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 2008 Slides by ADB 17 8

An aside: accumulator architecture One operand comes from memory The other comes from the accumulator CMPE12 Summer 2008 Slides by ADB 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 2008 Slides by ADB 19 9

The HC11 registers CMPE12 Summer 2008 Slides by ADB 20 Accumulators: A, B, andd 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 2008 Slides by ADB 21 10

Accumulators: A, B, andd 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 2008 Slides by ADB 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 2008 Slides by ADB 23 11

The HC11 has a stack set up at start-up Memory is byte-addressable HC11 User Stack 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 2008 Slides by ADB 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 A DE CD+E CCD TOP CMPE12 Summer 2008 Slides by ADB 25 12

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 2008 Slides by ADB 26 16-bit program counter, PC Program counter: PC 15 PC 0 CMPE12 Summer 2008 Slides by ADB 27 13

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 2008 Slides by ADB 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 2008 Slides by ADB 29 14

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 2008 Slides by ADB 30 /* header comments */ Structure of a source program #include <v2_18g3.asm>.sect.data // your variables here.sect.text // your code here main: // must have a main: function CMPE12 Summer 2008 Slides by ADB 31 15

#include <v2_18g3.asm> Example program echo.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 2008 Slides by ADB 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 2008 Slides by ADB 33 16

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 Example program factorial.asm (1/2) #include <v2_18g3.asm>.sect.data welcome:.asciz " Factorial!" prompt:.asciz "Fact is " blanks:.asciz " " input:.byte 0.sect.text main: ldx #welcome ldaa #1 // line 1 jsr LCDSTRING // write to LCD, expects in X ldx #blanks inca // line 2 jsr LCDSTRING // write to LCD ldx #prompt 19 jsr LCDSTRING // write to LCD CMPE12 Summer 2008 Slides by ADB 34 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 Example program factorial.asm (2/2) 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 2008 Slides by ADB 35 17

Compiling the program CMPE12 Summer 2008 Slides by ADB 41 CMPE12 Summer 2008 Slides by ADB 42 18

Downloading the program Just drag & drop CMPE12 Summer 2008 Slides by ADB 43 Running the program Note the LEDs: is the number correct? CMPE12 Summer 2008 Slides by ADB 44 19

Recommended exercises Write and run the Fibonacci program. CMPE12 Summer 2008 Slides by ADB 45 20