Download - HC11 Architecture
-
8/4/2019 HC11 Architecture
1/28
Motorola HC11
Fun with Microcontrollers andEmbedded Systems
-
8/4/2019 HC11 Architecture
2/28
Microcontrollers
What is a microcontroller?
A processorUsually not cutting edgeDependable
All major bugs well knownPredictable
Critical for real-time processingOn-chip peripherals and memory
Parallel and serial digital I/OAnalog I/OCounters and timersInternal ROM and/or EPROM
-
8/4/2019 HC11 Architecture
3/28
What are microcontrollers used in? Watches Microwaves Stereo Receivers
Some products that you might know:NASAs 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 processor
Microcontrollers
-
8/4/2019 HC11 Architecture
4/28
Microcontrollers
Microcontroller unit sales are 15x higher thanmicroprocessors. and are MUCH cheaper.
-
8/4/2019 HC11 Architecture
5/28
Microcontrollers
Microcontrollers are a large market
8-bit controllers are the largest, but not growing the fastest.
-
8/4/2019 HC11 Architecture
6/28
Microcontrollers
8-bit microcontroller growth rate for 2003 is at 9.42%.
Microcontroller growth rate in general is 11.5%.
8-bit controllers loosing market share in 2003. Was62.36% in 1998 to 56.76% in 2003.
16- and 32-bit and higher are on the rise. They willdouble their unit market share from 15.11% in 1998 to31.56% in 2003, decreasing 4-bit and 8-bit devices.
But, in 2003, the 8-bit microcontrollers will outnumberthe higher bit units by almost 80% in the market place.
Source: Cahners In-Stat Group
-
8/4/2019 HC11 Architecture
7/28
Microcontrollers
So what languages are they being programmed in?
Assembly ~ 21% ~ 10%
C ~ 69% ~ 80%
C++ ~ 5% ~ 6%
Java ~ 1 % ~ 2%
Other ~ 3 % ~ 2%
1998-1999 1999-2000
Source: TRON Association Survey 1998/99 & 1999/2000
-
8/4/2019 HC11 Architecture
8/28
HC11
Motorola 68HC11M6801 processorROM (8KB), EEPROM (512B), RAM (256B)Counter/Timer system
A/D converterD/A in kitParallel I/OExpansion bus
To add more memory
Serial communication
-
8/4/2019 HC11 Architecture
9/28
HC11
HC11 Architecture
-
8/4/2019 HC11 Architecture
10/28
-
8/4/2019 HC11 Architecture
11/28
HC11 CPU
-
8/4/2019 HC11 Architecture
12/28
HC11 CPU
Condition CodesNot present for MIPS integer instructionsSingle-bit flags set appropriately for most instruction(several instructions do not, including push and pop)
C Carry/BorrowV OverflowZ ZeroN NegativeH Half-Carry
MAL code HC11 code What it does
bge $t0, 4, mylabel cmpa #4 Subtract AccA - 4, set CCR
bge mylabel Branch if
(CCR[Z]=1 OR CCR[N]=0)
-
8/4/2019 HC11 Architecture
13/28
HC11 CPU
Command RegisterBits set by the user to tell the processor how to dothings
I Interrupt MaskX XIRQ maskS Disable STOP instructions
-
8/4/2019 HC11 Architecture
14/28
HC11 Instructions
HC11 Instructions have variable lengths (not like MAL)Careful coding can keep applications small and able tofit in the EPROM
We dont have to worry about this since were usingExpansion Mode: there is extra memory in the microkits.
The opcode is always 1 byteAn additional 0-3 bytes specify the data to work with
-
8/4/2019 HC11 Architecture
15/28
HC11 Addressing
Addressing ModesMIPS (TAL) has:
HC11 has severalCheck opcode listings to see what modes workwith what instructions
And what condition codes are set
-
8/4/2019 HC11 Architecture
16/28
HC11 Addressing
Inherent addressingOpcode fully specifies operation; no addressingExamples:
INCB increment accumulator BASLA Arithmetic Shift Left accumulator APSHYPush index register Y onto stack
-
8/4/2019 HC11 Architecture
17/28
HC11 Addressing
Immediate addressing1 or 2 byte immediate depending on register involved(LDAA vs. LDD)ALWAYS include a #Several formats for different bases -- C-styleconstants instead of what is in the HC11manual (dont use !,$,@,%)
Decimal: LDAA #245
Hexadecimal: LDAA #0x61Octal: LDAA #041Binary: LDAA #0b11000011ASCII: LDAA #a
-
8/4/2019 HC11 Architecture
18/28
HC11 Addressing
Direct and enhanced addressing
Access an absolute memory locationEssentially the same mode, but with 8-bit (direct)or 16-bit (enhanced) addressesThe assembler will decide on which to use based
on how many bits are neededExample
// Your data starts at address 0x4000:.sect .datavar: .word 0x1000 // Allocate/initialize a wordvar1: .word 0xffff // Note: a word is 16 bits!
.sect .textSUBD var // Subtract [var] from D
SUBD 0x4000 // Subtract [var] from D
-
8/4/2019 HC11 Architecture
19/28
HC11 Addressing
Indexed addressingUses index register X or YSimilar to MAL lw $t0, 4($sp)
But can access memory and use it all at once!!Example
#define mydef 4 // cc preprocessor usedldx #var // Like MAL load address
addd 0,X // add contents of 0($X) to D// (Note addd X doesnt work)addd 2,X // add contents of 2($X) to Daddd mydef*2, X // add contents of 8($X) to D
-
8/4/2019 HC11 Architecture
20/28
HC11 Addressing
Relative addressingUsed for branches by the assemblerOffsets from128 to +128 bytesUse jumps for longer branches
-
8/4/2019 HC11 Architecture
21/28
HC11 Instructions
-
8/4/2019 HC11 Architecture
22/28
HC11 Instructions
-
8/4/2019 HC11 Architecture
23/28
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 SimulatorPROMPT: .asciz >
// (continued)
-
8/4/2019 HC11 Architecture
24/28
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 #SIGNONjsr OUTSTRING
loop: ldx #PROMPT // address of promptjsr OUTSTRING // write out to serial communications
// interface (to PC)jsr GETCHAR // get a character from SCI, returns in Ajsr OUTCHAR // write A to the SCIjsr OUTCRLF // write CR/LF to SCIjmp loop
-
8/4/2019 HC11 Architecture
25/28
Micro Kit Usage
Design environment:Edit & assemble on CATS machines
> hc11build file.asmDownload program to the PC
Upload to the microkit using serial cable
To use kits at home9-12V AC adapter
Serial download cableConnection to CATS machinesFree serial communication software (e.g. TeraTerm)
-
8/4/2019 HC11 Architecture
26/28
Micro Kit Usage
Always #include as part of your programSets up memory, including stack pointer
Jumps to your main labelAlso includes a basic library of I/O routinesTake a look at it!/afs/cats/courses/cmpe12c-rph/include/v2_18g3.asm
-
8/4/2019 HC11 Architecture
27/28
Example recursive routine
Fibonacci on the switches and LEDs
/* Input: A. Returns Ath Fibonacci term in accumulator A */fib: cmpa #2
bgt fibnot1ldaa #1 // return 1 if n
-
8/4/2019 HC11 Architecture
28/28
HC11 Summary
Microcontrollers are great little machines for dataI/O and data manipulationThe CISC-style programming makes ASM programmingeasierVariable instruction length can be a problem for
Word-aligned machinesSuper-scalar machinesPipelines
The RISC philosophy is toUse simple instructions and let the compiler optimize
Use loads and stores to support higher-speed registersNeither RISC, its CISC predecessors, nor CISCY RISC hasthe definitive advantage
Depends on application, architecture, and implementation.