Motorola MC68HC811E2 Microcontrollers

Slides:



Advertisements
Similar presentations
Microprocessors.
Advertisements

Dr. Rabie A. Ramadan Al-Azhar University Lecture 3
MC68HC11 System Overview. System block diagram (A8 version)
I/O Unit.
Processor System Architecture
ELEC 330 Digital Systems Engineering Dr. Ron Hayne
68HC11 Polling and Interrupts
The 68HC11 Microcontroller Minnesota State University, Mankato
H. Huang Transparency No.1-1 The 68HC11 Microcontroller Chapter 1: Introduction to 68HC11 The 68HC11 Microcontroller.
ECE 372 – Microcontroller Design Parallel IO Ports - Interrupts
Room: E-3-31 Phone: Dr Masri Ayob TK 2633 Microprocessor & Interfacing Lecture 1: Introduction to 8085 Assembly Language.
EET 2261 Unit 2 HCS12 Architecture
Rabel Talpur:12BME#025.  40-pin chip  Developed by Motorola in 1975  16 address lines and 8 data lines  Used only +5V.
ECE 265 – LECTURE 12 The Hardware Interface 8/22/ ECE265.
Lab 1 – Assembly Language and Interfacing Start date: Week 3 Due date: Week 4 1.
Input/Output mechanisms
created by :Gaurav Shrivastava
Physics 413 Chapter 1: Introduction to the HCS 12 Microcontroller.
Nurudeen Olayiwola Thomas Gutierrez
ECE 265 – LECTURE 8 The M68HC11 Basic Instruction Set The remaining instructions 10/20/ ECE265.
Interrupts and reset operations. Overview  Introduction to interrupts – What are they – How are they used  68HC11 interrupt mechanisms – Types of interrupts.
Physics 413 Chapter 4 A Fork in the Road LDAB # $ 13 here :ADDA # $ 24 DEC B BNE here WAI BNE is the new instruction. Branch if not equal to zero.
ELE22MIC Lecture 8 ASll Examples –16 Bit Counters –Buffalo Jump Table Interrupt processing (IRQ/RTI) Stack Frame & Base Pointer Wired OR.
ME4447/6405 The George W. Woodruff School of Mechanical Engineering ME4447/6405 Microprocessor Control of Manufacturing Systems and Introduction to Mechatronics.
George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ME 4447/6405 Microprocessor Control of Manufacturing Systems and Introduction.
INTRODUCTION TO MC 68HC11 MICROCONTROLLER. Block Diagram Of MC68HC11.
1 Interrupts, Resets Today: First Hour: Interrupts –Section 5.2 of Huang’s Textbook –In-class Activity #1 Second Hour: More Interrupts Section 5.2 of Huang’s.
ECE 265 – LECTURE 5 The M68HC11 Basic Instruction Set 12/8/ ECE265.
George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ME 4447/6405 Microprocessor Control of Manufacturing Systems and Introduction.
Addressing Modes MTT CPU08 Core Motorola CPU08 ADDRESSING MODES.
1 ECE 372 – Microcontroller Design Assembly Programming HCS12 Assembly Programming Addressing Modes Stack Operations Subroutines.
1 Introduction to Microcontroller Microcontroller Fundamentals & Programming.
Ch.2 Intro. To Assembly Language Programming
Ch.2 Intro. To Assembly Language Programming From Introduction to Embedded Systems: Interfacing to the Freescale 9s12 by Valvano, published by CENGAGE.
1 Microcontroller Fundamentals & Programming Addressing Modes.
System Integration Module MTT Motoola SYSTEM INTEGRATION MODULE (SIM)
Microcontroller Fundamentals & Programming Arithmetic Instructions.
Advanced Assembly Language Programming
Execution Architecture MTT CPU08 Core M CPU08 INTRODUCTION.
ECE 447: Lecture 11 Introduction to Programming in Assembly Language.
بسم الله الرحمن الرحيم MEMORY AND I/O.
George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ME 4447/6405 Microprocessor Control of Manufacturing Systems and Introduction.
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.
Computer Operating Properly Module MTT COMPUTER OPERATING PROPERLY MODULE (COP)
8085 INTERNAL ARCHITECTURE.  Upon completing this topic, you should be able to: State all the register available in the 8085 microprocessor and explain.
George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ME 4447/6405 Microprocessor Control of Manufacturing Systems and Introduction.
Introduction to Microcontroller Technology
Unit Microprocessor.
COURSE OUTCOMES OF Microprocessor and programming
Addressing Modes in Microprocessors
Atmega32 Architectural Overview
ECE 3430 – Intro to Microcomputer Systems
68HC11 Interrupts & Resets.
ECE 3430 – Intro to Microcomputer Systems
UNIT – Microcontroller.
Introduction to microprocessor (Continued) Unit 1 Lecture 2
ECE 3430 – Intro to Microcomputer Systems
ECE 3430 – Intro to Microcomputer Systems
ECE 3430 – Intro to Microcomputer Systems
Introduction of microprocessor
Introduction to Microprocessors and Microcontrollers
ME4447/6405 Microprocessor Control of Manufacturing Systems and
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
Interrupts.
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
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 MC68HC811E2 Microcontrollers

What will be covered within 3 classes Class 1 Friday March 14th (home work due Tuesday) What are Microcontrollers/Microprocessors Intro into the HC11 chip Registers, accumulators, Condition Code register, memory map and other components Class 2 Monday March 17th Motorola Language Code Data type and symbols Opcodes, Operands and addressing modes Class 3 (Tutorial) Tuesday March 18th Assembler programming Assembler Compiling Assembler Emulating All done using Oztech Electronics Software

Microprocessors Microprocessors are components that compute binary mathematical commands at a specified rate determined by either an internal or external oscillating input. Characterized by: Memory addresses registers Memory data registers Instruction registers Index registers Stack registers Accumulators Program counters Ex: Motorola Microprocessor 6800 (built in the 1980’s)

Microcontrollers Microcontrollers are microprocessors that have built in peripherals, such as communications ports, I/O ports and others. These devices do not offer physical access to the address register and are usually standalone. They offer a fast and compact control method with limited physical connections and tools.

What they are used for Remote monitoring equipment Car computer systems Automating equipment Cell phones Computers Palm Pilots Singing gift cards

Motorola MC68HC811E2 Microcontroller

HC11 Power saving (stop) and (wait) modes 2048 bytes of EEPROM 256 bytes of RAM 16 bit timer 8-bit pulse accumulator Real time interrupt circuit Computer operating properly (COP) watchdog system

HC11 Synchronous Serial Peripheral Interface (SPI) Asynchronous Non return to Zero (NRZ) serial Communication Interface (SCI) 8 channel, 8-bit analogue to digital (A/D) converters 38 general purpose I/O pins 16 bidirectional 11 input only, 11 output only Available in 52pin (PLCC) or 48 pin (DIP) packages

Internal Structure of the chip

Nomenclature and symboles Vdd and or Vss mean +5 volts. GND = ground or 0 volts PA1 means Port A pin 1 Vrl = voltage reference low Vrh = voltage reference high Some pins have more than one function, these must be setup prior to use. Default is shown in manual. Pins with a line above mean “not” or anti” polar. Thus when 0volts or a “low” is shown at the reset pin, the chip interprets as a 1 or a “high”.

Reset pin All chips have a master reset pin where a physical reset can occur. Used for emergencies Low power Frozen Testing Startup

Oscillator All CPUs need an oscillator to jump between commands. HC11 is a 4 cycle command chip Operates at 2Mhz with an 8Mhz cristal

Interrupt Request Queue There are many different interrupts on the HC11 Software IRQ (SIR) Multitude of input IRQ Negative Edge Sensitive Positive Edge Sensitive Non-maskable IRQ (XIRQ) Here nothing can stop the interrupt from occurring. Always an external interrupt pin

Port A Port A can be configured as: Four timer input capture (IC) Four timer output compare (OC) Combination of the two One pulse accumulator (PAI) General I/O (note directional limits)

Ports

Port B Port B can be configured for: General purpose output pins Simple Strobed output Often used for 8-bit data communication

Port C Port C pins can be configured for: General I/O Used for full handshake modes during parallel I/O Often used as multiplexed address/data signal communication

Port D Port D pins can be configured for: General I/O Serial Communication Interface (SCI) Serial Peripheral Interface (SPI)

Port E Port E pins can be configured for: General purpose I/O Analogue for digital input (A/D) Note: for high accuracy of A/D, do not read port E during sampling of A/D, as small disturbances can reduce the accuracy of the results.

Chip Layout

CPU Registers HC11 has five registers and two accumulators Accumulator D = accA + AccB to form a 16 bit accumulator

Condition Code Register (CCR) C = Carry bit, ex: 255+1 = 0 + carry high V = Overflow ex: 255+1 = 0 and v=1 as the sum has overflowed capacity Z = zero bit ex: 1-1 = 0, z=1 N = negative ex: 4-6 = $FD z=1 I = interrupt mask, enables inturrupts H = half carry (when carry is done from bit 3) X = X interrupt mask XIRQ (set only by hardware (XIRQ and Reset pins), cleared only by software) S = Stop disable (sleep mode mask)

Program Counter The program counter always points to the next instruction location to be executed. 16 bit register

Stack pointer Stack is usually initialized at the top of memory and works down The program is located at the bottom of memory and works up If the stack grows too big, it may overwrite the program, causing a fatal crash HC11 has 256 bytes of RAM for the stack 16 bit register

Index Registers HC11 has two index registers X & Y are 16 bits wide Used to index memory fetch or storage of large numbers

Accumulators Accumulator A is 8 bits long Accumulator B is 8 bits long Accumulator D = A + B, where B is the low byte and A is the high byte. AccD is used for large number handling AccA and AccB are the main handlers of numbers within a program

Memory Map

Memory Map 256 Bytes of RAM at top of memory address 2K EEPROM from $F800 to $FFFF 64 byte register block is mapped initially starting from $1000 (this includes mapped address for ports, pins and internal configuration setup) All these can be remapped if needed

End of Day 1 Assignment Part1 Part2 Given a input on the lower nibble (4 bit) of PortC, increment a counter by the input value. Display counter output on PortB (8 bit) Give a block diagram of events, decision and I/O Part2 Give a block diagram of a delay loop Code the delay loop Q: Calculate the time it takes to cycle through your delay loop. Hint: use a nested loop

Example of Block Diagrams

Example 2 of flow diagram

Motorola MC68HC811E2 Microcontrollers Day 2

Topics that will be covered Motorola Language Code Data type and symbols Opcodes, Operands and addressing modes

Data types The default numbering system is decimal in most compilers Hexadecimal number are represented by a $ symbol. Ex: $FF = 255 decimal A number is defined by a# ex1: #45 = 45 decimal. Ex2: #$45 = 69 decimal Binary number are identified by a b. ex: #b101010 = #$2A = #42 decimal Octave numbers are identified by an o ex: #o10 = #$9 = #9 decimal

Instruction Set (hand out in class) Mnemonic = command Operation = what it does Description = description of how it does it Addressing mode = the way it does it Opcode = machine code that the HC11 sees Cycles = number of cycles needed to compute CCR = affected condition code after execution

Addressing modes There are many ways of executing commands. There are six different addressing modes Immediate Direct Extended Indexed Inherent relative

Immediate Argument is contained in the byte(s) immediately following the opcode. Number of bytes following the opcode matches the size of the register or memory location being operated on. The effective address is the address of the byte following the instruction

Example of Immediate Source list: LDAA #$55 ‘load 55 hex into accA Object code: Memory location Memory contents 0100 86 0101 55

Inherent (accumulator/memory) All information necessary to execute the instruction is contained in the opcode. Operations that use only the index register or accumulators, as well as control instructions with no arguments, are included in this addressing mode. These are one-byte or two-byte instructions

Example of Inherent Source list: PSHA ‘push accA to stack Object code: Memory location Memory contents 0100 36 Note: SP = SP -1

Direct addressing mode The address is found in the next memory location following the opcode This enables addressing the first page of memory (256 bytes) Execution time is reduced due to less consumption of space and movement of bits

Example of direct Source list: LDAA $55 ‘load contents from address $0055 hex into accA Object code: Memory location Memory contents 0100 96 0101 55 … 0055 XX Note: After insturction, accA = XX

Indexed Addressing Mode The offset, found in the second memory location of the instruction, is added to the contents of the index register to form a new effective address The effective address is held in a temporary address register so that the contents of the index register are not changed

Example of Indexed Source list: ‘X=#$1000 LDAA #$55,X ‘load contents from address ($55 + X) hex into accA Object code: Memory location Memory contents 0100 A6 0101 55 … 1055 YY Note: After insturction, accA = YY

Extended Addressing mode Used to address locations in full memory map 2nd memory location = address high byte 3rd memory location = address low byte

Example of Extended Source list: LDAA $2055 ‘load contents from address $2055 hex into accA Object code: Memory location Memory contents 0100 B6 0101 20 0110 55 … 2055 ZZ Note: After instruction, accA = ZZ

Relative Addressing Mode Used for branch type instructions Program control may be transferred to some place other than the next sequential memory location Transfer is referenced from the next instruction which the MCU would execute if it did not transfer control 2 byte instruction 2nd byte contains the offset, which is the number of memory locations to branch over Offset is expressed as an 8 bit 2’s compliment number

Example of Relative Branch forward example Source list: BRA #$20 ‘branch forward 32 +1 positions Object code: Memory location Memory contents 0100 20 0101 20 0110 55 … 100100 RR 100101 DD Note: After branch, PC = 100110 and executing DD opcode Note2: Note that opcode for BRA = 20hex, and so is the jump. This is why a miscalculation of branching can crash your program

Example of Relative Branch Backwards example Source list: BRA #$FE ‘branch backwards 2 - 1 positions Object code: Memory location Memory contents 0010 YY 0011 XX 0100 20 ‘BRA #$FE 0101 FE 0110 55 … 100100 RR 100101 DD Note: After branch, PC = 100 and executing 20 opcode Note2: Infinit loop

Subroutines Branch to subroutine will push the PC onto the stack This allows the program to return to the program once the subroutine has been executed. F800 BSR SUB FD00 SUB NOP FD01 NOP FD02 RTS Memory map 00FF 02 00FE F8

Useful Opcodes ABA ADDA ANDA BCC BEQ BITA BRA BRSET CLC CLI CLR CLRA CMPA COM DEC DECA DEX INCA INS INX JSR LDAA LSR NEGA RTI RTS SEC SEI STAA STX SUBA SWI TAB WAI

Program example1 Example1: Determine: ORG $0000 LDX #$0060 LDAA $02 LDAB 2,X ABA ORG $0060 FCB $70,$72,$74,$76 END S=1, X=0, I =0 Determine: accA = _________ accB = _________ PC = ___________ CCR = __________binary CCR = __________Hex

Program example1 accA = $60+ $74 = $D4 Example1: accB = $74 ORG $0000 PC = $0008 CCR = 1000 1000b CCR = $88 Example1: ORG $0000 LDX #$0060 LDAA $02 LDAB 2,X ABA ORG $0060 FCB $70,$72,$74,$76 END

Program example2 Example2: ORG $0F00 LDS #$10FF LDX #$0F00 LDAA 2,X LDAB #01 PSHA PSHB BSR SUB1 NOP ORG$0F50 PULA PULB ABA RTS END S=1, X=0, I =0 Determine: accA= accB= PC = CCR = SP = IX = Does the code work? Explain.

Program example2 Example2: ORG $F800 LDS #$00FF LDX #$F800 LDAA 2,X LDAB #01 PSHA PSHB BSR SUB1 NOP ORG$F850 PULA PULB ABA RTS END S=1, X=0, I =0 Determine: accA= $FF, $F8, $06 accB= $01, $0E PC = $01FF CCR = $A1 SP = $01FF IX = $0F00 00FF FF 00FE 01 00FD 0E 00FC F8 The problem is that we return from the subroutine to a non-controlled position. Program will crash!

Program example3 Example3: ORG $F800 SEI LDX #$FA00 CLR 1,X CLR 3,X LDAA #$FF STAA 2,X CLR 0,X LDAA $02 STAA 1,X STAA 3,X LDAB #$FF STAB 2,X LDAA 0,X ABA END S=1, X=0, I =0 Determine: accA= accB= PC = CCR = IX = Does the code work? Explain.

Program example3 Example3: ORG $F800 SEI LDX #$F8A0 CLR 1,X CLR 3,X LDAA #$FF STAA 2,X CLR 0,X LDAA $02 STAA 1,X STAA 3,X LDAB #$FF STAB 2,X LDAA 0,X ABA END S=1, X=0, I =0 Determine: accA= $FF, $00, $FF accB= $FF PC = $F81C CCR = $88 IX = $F8A0 FA00 00 FA01 00, FA FA02 FF, FF FA03 00, FA Does the code work? Explain. Yes, the code is fully functioning

Example of Flow Diagram

Assignment Review Setup code for the Main Program for next Lab Setup code for delay loop using nested loops

Your Flow Diagram Initialize Pause on? BSR Delay Input PortC Add Input with accA Output accA To PortB

Delay Loop Push A &B Init A & B DecA A=0? RTS Pull A & B DecB B=0?

Assignement2 ORG $0000 SEI LDS #$0100 LDAA #03 CLRB BSR SUB ABA SUB INCB PSHB DECA BEQ CONT CONT PULB RTS END INITIALLY: S=1, X=0, I =0 CCR = SXHINZVC Determine: accA= accB= PC = SP = CCR = What does this program do?