Motorola MC68HC811E2 Microcontrollers. What will be covered within 3 classes Class 1 Friday March 14...
-
Upload
lilian-page -
Category
Documents
-
view
216 -
download
0
Transcript of Motorola MC68HC811E2 Microcontrollers. What will be covered within 3 classes Class 1 Friday March 14...
![Page 1: Motorola MC68HC811E2 Microcontrollers. What will be covered within 3 classes Class 1 Friday March 14 th (home work due Tuesday) What are Microcontrollers/Microprocessors.](https://reader035.fdocuments.us/reader035/viewer/2022062409/5697bfa71a28abf838c990dd/html5/thumbnails/1.jpg)
Motorola MC68HC811E2Microcontrollers
![Page 2: Motorola MC68HC811E2 Microcontrollers. What will be covered within 3 classes Class 1 Friday March 14 th (home work due Tuesday) What are Microcontrollers/Microprocessors.](https://reader035.fdocuments.us/reader035/viewer/2022062409/5697bfa71a28abf838c990dd/html5/thumbnails/2.jpg)
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
![Page 3: Motorola MC68HC811E2 Microcontrollers. What will be covered within 3 classes Class 1 Friday March 14 th (home work due Tuesday) What are Microcontrollers/Microprocessors.](https://reader035.fdocuments.us/reader035/viewer/2022062409/5697bfa71a28abf838c990dd/html5/thumbnails/3.jpg)
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)
![Page 4: Motorola MC68HC811E2 Microcontrollers. What will be covered within 3 classes Class 1 Friday March 14 th (home work due Tuesday) What are Microcontrollers/Microprocessors.](https://reader035.fdocuments.us/reader035/viewer/2022062409/5697bfa71a28abf838c990dd/html5/thumbnails/4.jpg)
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.
![Page 5: Motorola MC68HC811E2 Microcontrollers. What will be covered within 3 classes Class 1 Friday March 14 th (home work due Tuesday) What are Microcontrollers/Microprocessors.](https://reader035.fdocuments.us/reader035/viewer/2022062409/5697bfa71a28abf838c990dd/html5/thumbnails/5.jpg)
What they are used for
Remote monitoring equipmentCar computer systemsAutomating equipmentCell phonesComputersPalm PilotsSinging gift cards
![Page 6: Motorola MC68HC811E2 Microcontrollers. What will be covered within 3 classes Class 1 Friday March 14 th (home work due Tuesday) What are Microcontrollers/Microprocessors.](https://reader035.fdocuments.us/reader035/viewer/2022062409/5697bfa71a28abf838c990dd/html5/thumbnails/6.jpg)
Motorola MC68HC811E2Microcontroller
![Page 7: Motorola MC68HC811E2 Microcontrollers. What will be covered within 3 classes Class 1 Friday March 14 th (home work due Tuesday) What are Microcontrollers/Microprocessors.](https://reader035.fdocuments.us/reader035/viewer/2022062409/5697bfa71a28abf838c990dd/html5/thumbnails/7.jpg)
HC11
Power saving (stop) and (wait) modes2048 bytes of EEPROM 256 bytes of RAM16 bit timer8-bit pulse accumulatorReal time interrupt circuitComputer operating properly (COP) watchdog system
![Page 8: Motorola MC68HC811E2 Microcontrollers. What will be covered within 3 classes Class 1 Friday March 14 th (home work due Tuesday) What are Microcontrollers/Microprocessors.](https://reader035.fdocuments.us/reader035/viewer/2022062409/5697bfa71a28abf838c990dd/html5/thumbnails/8.jpg)
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) converters38 general purpose I/O pins 16 bidirectional 11 input only, 11 output only
Available in 52pin (PLCC) or 48 pin (DIP) packages
![Page 9: Motorola MC68HC811E2 Microcontrollers. What will be covered within 3 classes Class 1 Friday March 14 th (home work due Tuesday) What are Microcontrollers/Microprocessors.](https://reader035.fdocuments.us/reader035/viewer/2022062409/5697bfa71a28abf838c990dd/html5/thumbnails/9.jpg)
Internal Structure of the chip
![Page 10: Motorola MC68HC811E2 Microcontrollers. What will be covered within 3 classes Class 1 Friday March 14 th (home work due Tuesday) What are Microcontrollers/Microprocessors.](https://reader035.fdocuments.us/reader035/viewer/2022062409/5697bfa71a28abf838c990dd/html5/thumbnails/10.jpg)
Nomenclature and symboles
Vdd and or Vss mean +5 volts.GND = ground or 0 voltsPA1 means Port A pin 1Vrl = voltage reference lowVrh = voltage reference highSome 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”.
![Page 11: Motorola MC68HC811E2 Microcontrollers. What will be covered within 3 classes Class 1 Friday March 14 th (home work due Tuesday) What are Microcontrollers/Microprocessors.](https://reader035.fdocuments.us/reader035/viewer/2022062409/5697bfa71a28abf838c990dd/html5/thumbnails/11.jpg)
Reset pin
All chips have a master reset pin where a physical reset can occur. Used for emergencies Low power Frozen Testing Startup
![Page 12: Motorola MC68HC811E2 Microcontrollers. What will be covered within 3 classes Class 1 Friday March 14 th (home work due Tuesday) What are Microcontrollers/Microprocessors.](https://reader035.fdocuments.us/reader035/viewer/2022062409/5697bfa71a28abf838c990dd/html5/thumbnails/12.jpg)
OscillatorAll CPUs need an oscillator to jump between commands. HC11 is a 4 cycle command chipOperates at 2Mhz with an 8Mhz cristal
![Page 13: Motorola MC68HC811E2 Microcontrollers. What will be covered within 3 classes Class 1 Friday March 14 th (home work due Tuesday) What are Microcontrollers/Microprocessors.](https://reader035.fdocuments.us/reader035/viewer/2022062409/5697bfa71a28abf838c990dd/html5/thumbnails/13.jpg)
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
![Page 14: Motorola MC68HC811E2 Microcontrollers. What will be covered within 3 classes Class 1 Friday March 14 th (home work due Tuesday) What are Microcontrollers/Microprocessors.](https://reader035.fdocuments.us/reader035/viewer/2022062409/5697bfa71a28abf838c990dd/html5/thumbnails/14.jpg)
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)
![Page 15: Motorola MC68HC811E2 Microcontrollers. What will be covered within 3 classes Class 1 Friday March 14 th (home work due Tuesday) What are Microcontrollers/Microprocessors.](https://reader035.fdocuments.us/reader035/viewer/2022062409/5697bfa71a28abf838c990dd/html5/thumbnails/15.jpg)
Ports
![Page 16: Motorola MC68HC811E2 Microcontrollers. What will be covered within 3 classes Class 1 Friday March 14 th (home work due Tuesday) What are Microcontrollers/Microprocessors.](https://reader035.fdocuments.us/reader035/viewer/2022062409/5697bfa71a28abf838c990dd/html5/thumbnails/16.jpg)
Port B
Port B can be configured for: General purpose output pins Simple Strobed output Often used for 8-bit data
communication
![Page 17: Motorola MC68HC811E2 Microcontrollers. What will be covered within 3 classes Class 1 Friday March 14 th (home work due Tuesday) What are Microcontrollers/Microprocessors.](https://reader035.fdocuments.us/reader035/viewer/2022062409/5697bfa71a28abf838c990dd/html5/thumbnails/17.jpg)
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
![Page 18: Motorola MC68HC811E2 Microcontrollers. What will be covered within 3 classes Class 1 Friday March 14 th (home work due Tuesday) What are Microcontrollers/Microprocessors.](https://reader035.fdocuments.us/reader035/viewer/2022062409/5697bfa71a28abf838c990dd/html5/thumbnails/18.jpg)
Port D
Port D pins can be configured for: General I/O Serial Communication Interface (SCI) Serial Peripheral Interface (SPI)
![Page 19: Motorola MC68HC811E2 Microcontrollers. What will be covered within 3 classes Class 1 Friday March 14 th (home work due Tuesday) What are Microcontrollers/Microprocessors.](https://reader035.fdocuments.us/reader035/viewer/2022062409/5697bfa71a28abf838c990dd/html5/thumbnails/19.jpg)
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.
![Page 20: Motorola MC68HC811E2 Microcontrollers. What will be covered within 3 classes Class 1 Friday March 14 th (home work due Tuesday) What are Microcontrollers/Microprocessors.](https://reader035.fdocuments.us/reader035/viewer/2022062409/5697bfa71a28abf838c990dd/html5/thumbnails/20.jpg)
Chip Layout
![Page 21: Motorola MC68HC811E2 Microcontrollers. What will be covered within 3 classes Class 1 Friday March 14 th (home work due Tuesday) What are Microcontrollers/Microprocessors.](https://reader035.fdocuments.us/reader035/viewer/2022062409/5697bfa71a28abf838c990dd/html5/thumbnails/21.jpg)
CPU Registers
HC11 has five registers and two accumulatorsAccumulator D = accA + AccB to form a 16 bit accumulator
![Page 22: Motorola MC68HC811E2 Microcontrollers. What will be covered within 3 classes Class 1 Friday March 14 th (home work due Tuesday) What are Microcontrollers/Microprocessors.](https://reader035.fdocuments.us/reader035/viewer/2022062409/5697bfa71a28abf838c990dd/html5/thumbnails/22.jpg)
Condition Code Register (CCR)
C = Carry bit, ex: 255+1 = 0 + carry highV = Overflow ex: 255+1 = 0 and v=1 as the sum has overflowed capacityZ = zero bit ex: 1-1 = 0, z=1N = negative ex: 4-6 = $FD z=1I = interrupt mask, enables inturruptsH = 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)
![Page 23: Motorola MC68HC811E2 Microcontrollers. What will be covered within 3 classes Class 1 Friday March 14 th (home work due Tuesday) What are Microcontrollers/Microprocessors.](https://reader035.fdocuments.us/reader035/viewer/2022062409/5697bfa71a28abf838c990dd/html5/thumbnails/23.jpg)
Program Counter
The program counter always points to the next instruction location to be executed. 16 bit register
![Page 24: Motorola MC68HC811E2 Microcontrollers. What will be covered within 3 classes Class 1 Friday March 14 th (home work due Tuesday) What are Microcontrollers/Microprocessors.](https://reader035.fdocuments.us/reader035/viewer/2022062409/5697bfa71a28abf838c990dd/html5/thumbnails/24.jpg)
Stack pointer
Stack is usually initialized at the top of memory and works downThe program is located at the bottom of memory and works upIf the stack grows too big, it may overwrite the program, causing a fatal crashHC11 has 256 bytes of RAM for the stack16 bit register
![Page 25: Motorola MC68HC811E2 Microcontrollers. What will be covered within 3 classes Class 1 Friday March 14 th (home work due Tuesday) What are Microcontrollers/Microprocessors.](https://reader035.fdocuments.us/reader035/viewer/2022062409/5697bfa71a28abf838c990dd/html5/thumbnails/25.jpg)
Index Registers
HC11 has two index registersX & Y are 16 bits wideUsed to index memory fetch or storage of large numbers
![Page 26: Motorola MC68HC811E2 Microcontrollers. What will be covered within 3 classes Class 1 Friday March 14 th (home work due Tuesday) What are Microcontrollers/Microprocessors.](https://reader035.fdocuments.us/reader035/viewer/2022062409/5697bfa71a28abf838c990dd/html5/thumbnails/26.jpg)
Accumulators
Accumulator A is 8 bits longAccumulator B is 8 bits longAccumulator D = A + B, where B is the low byte and A is the high byte. AccD is used for large number handlingAccA and AccB are the main handlers of numbers within a program
![Page 27: Motorola MC68HC811E2 Microcontrollers. What will be covered within 3 classes Class 1 Friday March 14 th (home work due Tuesday) What are Microcontrollers/Microprocessors.](https://reader035.fdocuments.us/reader035/viewer/2022062409/5697bfa71a28abf838c990dd/html5/thumbnails/27.jpg)
Memory Map
![Page 28: Motorola MC68HC811E2 Microcontrollers. What will be covered within 3 classes Class 1 Friday March 14 th (home work due Tuesday) What are Microcontrollers/Microprocessors.](https://reader035.fdocuments.us/reader035/viewer/2022062409/5697bfa71a28abf838c990dd/html5/thumbnails/28.jpg)
Memory Map
256 Bytes of RAM at top of memory address2K EEPROM from $F800 to $FFFF64 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
![Page 29: Motorola MC68HC811E2 Microcontrollers. What will be covered within 3 classes Class 1 Friday March 14 th (home work due Tuesday) What are Microcontrollers/Microprocessors.](https://reader035.fdocuments.us/reader035/viewer/2022062409/5697bfa71a28abf838c990dd/html5/thumbnails/29.jpg)
End of Day 1
Assignment Part1
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
![Page 30: Motorola MC68HC811E2 Microcontrollers. What will be covered within 3 classes Class 1 Friday March 14 th (home work due Tuesday) What are Microcontrollers/Microprocessors.](https://reader035.fdocuments.us/reader035/viewer/2022062409/5697bfa71a28abf838c990dd/html5/thumbnails/30.jpg)
Example of Block Diagrams
![Page 31: Motorola MC68HC811E2 Microcontrollers. What will be covered within 3 classes Class 1 Friday March 14 th (home work due Tuesday) What are Microcontrollers/Microprocessors.](https://reader035.fdocuments.us/reader035/viewer/2022062409/5697bfa71a28abf838c990dd/html5/thumbnails/31.jpg)
Example 2 of flow diagram
![Page 32: Motorola MC68HC811E2 Microcontrollers. What will be covered within 3 classes Class 1 Friday March 14 th (home work due Tuesday) What are Microcontrollers/Microprocessors.](https://reader035.fdocuments.us/reader035/viewer/2022062409/5697bfa71a28abf838c990dd/html5/thumbnails/32.jpg)
Motorola MC68HC811E2Microcontrollers
Day 2
![Page 33: Motorola MC68HC811E2 Microcontrollers. What will be covered within 3 classes Class 1 Friday March 14 th (home work due Tuesday) What are Microcontrollers/Microprocessors.](https://reader035.fdocuments.us/reader035/viewer/2022062409/5697bfa71a28abf838c990dd/html5/thumbnails/33.jpg)
Topics that will be covered
Motorola Language CodeData type and symbolsOpcodes, Operands and addressing modes
![Page 34: Motorola MC68HC811E2 Microcontrollers. What will be covered within 3 classes Class 1 Friday March 14 th (home work due Tuesday) What are Microcontrollers/Microprocessors.](https://reader035.fdocuments.us/reader035/viewer/2022062409/5697bfa71a28abf838c990dd/html5/thumbnails/34.jpg)
Data types
The default numbering system is decimal in most compilersHexadecimal number are represented by a $ symbol. Ex: $FF = 255 decimalA number is defined by a# ex1: #45 = 45 decimal. Ex2: #$45 = 69 decimalBinary number are identified by a b. ex: #b101010 = #$2A = #42 decimalOctave numbers are identified by an o ex: #o10 = #$9 = #9 decimal
![Page 35: Motorola MC68HC811E2 Microcontrollers. What will be covered within 3 classes Class 1 Friday March 14 th (home work due Tuesday) What are Microcontrollers/Microprocessors.](https://reader035.fdocuments.us/reader035/viewer/2022062409/5697bfa71a28abf838c990dd/html5/thumbnails/35.jpg)
Instruction Set (hand out in class)
Mnemonic = commandOperation = what it doesDescription = description of how it does itAddressing mode = the way it does itOpcode = machine code that the HC11 seesCycles = number of cycles needed to computeCCR = affected condition code after execution
![Page 36: Motorola MC68HC811E2 Microcontrollers. What will be covered within 3 classes Class 1 Friday March 14 th (home work due Tuesday) What are Microcontrollers/Microprocessors.](https://reader035.fdocuments.us/reader035/viewer/2022062409/5697bfa71a28abf838c990dd/html5/thumbnails/36.jpg)
Addressing modes
There are many ways of executing commands. There are six different addressing modes Immediate Direct Extended Indexed Inherent relative
![Page 37: Motorola MC68HC811E2 Microcontrollers. What will be covered within 3 classes Class 1 Friday March 14 th (home work due Tuesday) What are Microcontrollers/Microprocessors.](https://reader035.fdocuments.us/reader035/viewer/2022062409/5697bfa71a28abf838c990dd/html5/thumbnails/37.jpg)
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
![Page 38: Motorola MC68HC811E2 Microcontrollers. What will be covered within 3 classes Class 1 Friday March 14 th (home work due Tuesday) What are Microcontrollers/Microprocessors.](https://reader035.fdocuments.us/reader035/viewer/2022062409/5697bfa71a28abf838c990dd/html5/thumbnails/38.jpg)
Example of Immediate
Source list:LDAA #$55 ‘load 55 hex into accA
Object code:Memory location Memory contents0100 860101 55
![Page 39: Motorola MC68HC811E2 Microcontrollers. What will be covered within 3 classes Class 1 Friday March 14 th (home work due Tuesday) What are Microcontrollers/Microprocessors.](https://reader035.fdocuments.us/reader035/viewer/2022062409/5697bfa71a28abf838c990dd/html5/thumbnails/39.jpg)
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
![Page 40: Motorola MC68HC811E2 Microcontrollers. What will be covered within 3 classes Class 1 Friday March 14 th (home work due Tuesday) What are Microcontrollers/Microprocessors.](https://reader035.fdocuments.us/reader035/viewer/2022062409/5697bfa71a28abf838c990dd/html5/thumbnails/40.jpg)
Example of Inherent
Source list:PSHA ‘push accA to stack
Object code:Memory location Memory contents0100 36
Note: SP = SP -1
![Page 41: Motorola MC68HC811E2 Microcontrollers. What will be covered within 3 classes Class 1 Friday March 14 th (home work due Tuesday) What are Microcontrollers/Microprocessors.](https://reader035.fdocuments.us/reader035/viewer/2022062409/5697bfa71a28abf838c990dd/html5/thumbnails/41.jpg)
Direct addressing mode
The address is found in the next memory location following the opcodeThis enables addressing the first page of memory (256 bytes)Execution time is reduced due to less consumption of space and movement of bits
![Page 42: Motorola MC68HC811E2 Microcontrollers. What will be covered within 3 classes Class 1 Friday March 14 th (home work due Tuesday) What are Microcontrollers/Microprocessors.](https://reader035.fdocuments.us/reader035/viewer/2022062409/5697bfa71a28abf838c990dd/html5/thumbnails/42.jpg)
Example of directSource list:
LDAA $55 ‘load contents from address $0055 hex into accA
Object code:Memory location Memory contents0100 960101 55…0055 XX
Note: After insturction, accA = XX
![Page 43: Motorola MC68HC811E2 Microcontrollers. What will be covered within 3 classes Class 1 Friday March 14 th (home work due Tuesday) What are Microcontrollers/Microprocessors.](https://reader035.fdocuments.us/reader035/viewer/2022062409/5697bfa71a28abf838c990dd/html5/thumbnails/43.jpg)
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 addressThe effective address is held in a temporary address register so that the contents of the index register are not changed
![Page 44: Motorola MC68HC811E2 Microcontrollers. What will be covered within 3 classes Class 1 Friday March 14 th (home work due Tuesday) What are Microcontrollers/Microprocessors.](https://reader035.fdocuments.us/reader035/viewer/2022062409/5697bfa71a28abf838c990dd/html5/thumbnails/44.jpg)
Example of IndexedSource list: ‘X=#$1000
LDAA #$55,X ‘load contents from address ($55 + X) hex into accA
Object code:Memory location Memory contents0100 A60101 55…1055 YY
Note: After insturction, accA = YY
![Page 45: Motorola MC68HC811E2 Microcontrollers. What will be covered within 3 classes Class 1 Friday March 14 th (home work due Tuesday) What are Microcontrollers/Microprocessors.](https://reader035.fdocuments.us/reader035/viewer/2022062409/5697bfa71a28abf838c990dd/html5/thumbnails/45.jpg)
Extended Addressing mode
Used to address locations in full memory map2nd memory location = address high byte3rd memory location = address low byte
![Page 46: Motorola MC68HC811E2 Microcontrollers. What will be covered within 3 classes Class 1 Friday March 14 th (home work due Tuesday) What are Microcontrollers/Microprocessors.](https://reader035.fdocuments.us/reader035/viewer/2022062409/5697bfa71a28abf838c990dd/html5/thumbnails/46.jpg)
Example of Extended
Source list: LDAA $2055 ‘load contents from address
$2055 hex into accA
Object code:Memory location Memory contents0100 B60101 200110 55…2055 ZZ
Note: After instruction, accA = ZZ
![Page 47: Motorola MC68HC811E2 Microcontrollers. What will be covered within 3 classes Class 1 Friday March 14 th (home work due Tuesday) What are Microcontrollers/Microprocessors.](https://reader035.fdocuments.us/reader035/viewer/2022062409/5697bfa71a28abf838c990dd/html5/thumbnails/47.jpg)
Relative Addressing ModeUsed for branch type instructionsProgram control may be transferred to some place other than the next sequential memory locationTransfer is referenced from the next instruction which the MCU would execute if it did not transfer control2 byte instruction2nd byte contains the offset, which is the number of memory locations to branch overOffset is expressed as an 8 bit 2’s compliment number
![Page 48: Motorola MC68HC811E2 Microcontrollers. What will be covered within 3 classes Class 1 Friday March 14 th (home work due Tuesday) What are Microcontrollers/Microprocessors.](https://reader035.fdocuments.us/reader035/viewer/2022062409/5697bfa71a28abf838c990dd/html5/thumbnails/48.jpg)
Example of RelativeBranch forward example
Source list: BRA #$20 ‘branch forward 32 +1 positions
Object code:Memory location Memory contents0100 200101 200110 55…100100 RR100101 DD
Note: After branch, PC = 100110 and executing DD opcodeNote2: Note that opcode for BRA = 20hex, and so is the
jump. This is why a miscalculation of branching can crash your program
![Page 49: Motorola MC68HC811E2 Microcontrollers. What will be covered within 3 classes Class 1 Friday March 14 th (home work due Tuesday) What are Microcontrollers/Microprocessors.](https://reader035.fdocuments.us/reader035/viewer/2022062409/5697bfa71a28abf838c990dd/html5/thumbnails/49.jpg)
Example of RelativeBranch Backwards example
Source list: BRA #$FE ‘branch backwards 2 - 1 positions
Object code:Memory location Memory contents0010 YY0011 XX0100 20 ‘BRA #$FE0101 FE0110 55…100100 RR100101 DD
Note: After branch, PC = 100 and executing 20 opcodeNote2: Infinit loop
![Page 50: Motorola MC68HC811E2 Microcontrollers. What will be covered within 3 classes Class 1 Friday March 14 th (home work due Tuesday) What are Microcontrollers/Microprocessors.](https://reader035.fdocuments.us/reader035/viewer/2022062409/5697bfa71a28abf838c990dd/html5/thumbnails/50.jpg)
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 NOPFD01 NOPFD02 RTS
Memory map00FF 0200FE F8
![Page 51: Motorola MC68HC811E2 Microcontrollers. What will be covered within 3 classes Class 1 Friday March 14 th (home work due Tuesday) What are Microcontrollers/Microprocessors.](https://reader035.fdocuments.us/reader035/viewer/2022062409/5697bfa71a28abf838c990dd/html5/thumbnails/51.jpg)
Useful OpcodesABAADDAANDABCCBEQBITABRABRSET
CLCCLICLRCLRACMPACOMDECDECA
DEXINCAINSINXJSRLDAALSRNEGA
RTIRTSSECSEISTAASTXSUBASWI
TABWAI
![Page 52: Motorola MC68HC811E2 Microcontrollers. What will be covered within 3 classes Class 1 Friday March 14 th (home work due Tuesday) What are Microcontrollers/Microprocessors.](https://reader035.fdocuments.us/reader035/viewer/2022062409/5697bfa71a28abf838c990dd/html5/thumbnails/52.jpg)
Program example1
Example1:ORG $0000LDX #$0060LDAA $02LDAB 2,XABA
ORG $0060FCB
$70,$72,$74,$76END
S=1, X=0, I =0
Determine:
accA = _________accB = _________PC = ___________CCR = __________binaryCCR = __________Hex
![Page 53: Motorola MC68HC811E2 Microcontrollers. What will be covered within 3 classes Class 1 Friday March 14 th (home work due Tuesday) What are Microcontrollers/Microprocessors.](https://reader035.fdocuments.us/reader035/viewer/2022062409/5697bfa71a28abf838c990dd/html5/thumbnails/53.jpg)
Program example1
accA = $60+ $74 = $D4accB = $74PC = $0008CCR = 1000 1000bCCR = $88
Example1:ORG $0000LDX #$0060LDAA $02LDAB 2,XABA
ORG $0060FCB
$70,$72,$74,$76END
![Page 54: Motorola MC68HC811E2 Microcontrollers. What will be covered within 3 classes Class 1 Friday March 14 th (home work due Tuesday) What are Microcontrollers/Microprocessors.](https://reader035.fdocuments.us/reader035/viewer/2022062409/5697bfa71a28abf838c990dd/html5/thumbnails/54.jpg)
Program example2Example2:
ORG $0F00LDS
#$10FFLDX
#$0F00LDAA 2,XLDAB #01PSHAPSHBBSR SUB1NOP
ORG$0F50PULAPULBABARTSEND
S=1, X=0, I =0 Determine:
accA=accB= PC = CCR = SP = IX =
Does the code work? Explain.
![Page 55: Motorola MC68HC811E2 Microcontrollers. What will be covered within 3 classes Class 1 Friday March 14 th (home work due Tuesday) What are Microcontrollers/Microprocessors.](https://reader035.fdocuments.us/reader035/viewer/2022062409/5697bfa71a28abf838c990dd/html5/thumbnails/55.jpg)
Program example2Example2:
ORG $F800LDS
#$00FFLDX
#$F800LDAA 2,XLDAB #01PSHAPSHBBSR SUB1NOP
ORG$F850PULAPULBABARTSEND
S=1, X=0, I =0 Determine:
accA= $FF, $F8, $06accB= $01, $0EPC = $01FFCCR = $A1SP = $01FFIX = $0F00
00FF FF00FE 0100FD 0E00FC F8
The problem is that we return from the subroutine to a non-controlled position. Program will crash!
![Page 56: Motorola MC68HC811E2 Microcontrollers. What will be covered within 3 classes Class 1 Friday March 14 th (home work due Tuesday) What are Microcontrollers/Microprocessors.](https://reader035.fdocuments.us/reader035/viewer/2022062409/5697bfa71a28abf838c990dd/html5/thumbnails/56.jpg)
Program example3Example3:
ORG $F800SEILDX #$FA00CLR 1,XCLR 3,XLDAA #$FFSTAA 2,XCLR 0,XLDAA $02STAA 1,XSTAA 3,XLDAB #$FFSTAB 2,XLDAA 0,XABAEND
S=1, X=0, I =0Determine:
accA=accB= PC = CCR = IX =
Does the code work? Explain.
![Page 57: Motorola MC68HC811E2 Microcontrollers. What will be covered within 3 classes Class 1 Friday March 14 th (home work due Tuesday) What are Microcontrollers/Microprocessors.](https://reader035.fdocuments.us/reader035/viewer/2022062409/5697bfa71a28abf838c990dd/html5/thumbnails/57.jpg)
Program example3Example3:
ORG $F800SEILDX #$F8A0CLR 1,XCLR 3,XLDAA #$FFSTAA 2,XCLR 0,XLDAA $02STAA 1,XSTAA 3,XLDAB #$FFSTAB 2,XLDAA 0,XABAEND
S=1, X=0, I =0 Determine:
accA= $FF, $00, $FFaccB= $FFPC = $F81CCCR = $88IX = $F8A0
FA00 00FA01 00, FAFA02 FF, FFFA03 00, FA
Does the code work? Explain.
Yes, the code is fully functioning
![Page 58: Motorola MC68HC811E2 Microcontrollers. What will be covered within 3 classes Class 1 Friday March 14 th (home work due Tuesday) What are Microcontrollers/Microprocessors.](https://reader035.fdocuments.us/reader035/viewer/2022062409/5697bfa71a28abf838c990dd/html5/thumbnails/58.jpg)
Example of Flow Diagram
![Page 59: Motorola MC68HC811E2 Microcontrollers. What will be covered within 3 classes Class 1 Friday March 14 th (home work due Tuesday) What are Microcontrollers/Microprocessors.](https://reader035.fdocuments.us/reader035/viewer/2022062409/5697bfa71a28abf838c990dd/html5/thumbnails/59.jpg)
Assignment Review
Setup code for the Main Program for next LabSetup code for delay loop using nested loops
![Page 60: Motorola MC68HC811E2 Microcontrollers. What will be covered within 3 classes Class 1 Friday March 14 th (home work due Tuesday) What are Microcontrollers/Microprocessors.](https://reader035.fdocuments.us/reader035/viewer/2022062409/5697bfa71a28abf838c990dd/html5/thumbnails/60.jpg)
Your Flow DiagramInitialize
Pauseon?
Input PortC
Add Inputwith accA
Output accATo PortB
BSR Delay
![Page 61: Motorola MC68HC811E2 Microcontrollers. What will be covered within 3 classes Class 1 Friday March 14 th (home work due Tuesday) What are Microcontrollers/Microprocessors.](https://reader035.fdocuments.us/reader035/viewer/2022062409/5697bfa71a28abf838c990dd/html5/thumbnails/61.jpg)
Delay Loop Push A &B
Init A & B
DecA
A=0?Pull A & B
B=0?
DecBRTS
![Page 62: Motorola MC68HC811E2 Microcontrollers. What will be covered within 3 classes Class 1 Friday March 14 th (home work due Tuesday) What are Microcontrollers/Microprocessors.](https://reader035.fdocuments.us/reader035/viewer/2022062409/5697bfa71a28abf838c990dd/html5/thumbnails/62.jpg)
Assignement2ORG $0000SEILDS
#$0100LDAA #03CLRBBSR SUBABA
ORG $0080SUB INCB
PSHBDECABEQ CONTBSR SUB
CONT PULBABARTSEND
INITIALLY: S=1, X=0, I =0CCR = SXHINZVCDetermine:
accA=accB= PC = SP = CCR =
What does this program do?