Motorola's 68HC11x Family of 8-bit Micro-controllers
by Jonathan Sawyer
CS411 - October 16, 2007
About the 68HC11
- An extention of Motorola's 6800 embedded processor which was built in 1975
- The 6800 had 54 instructions
- But the 68HC11 has 91 more instructions and was designed to be backwards compatible with the 6800
- There are a lot of variations of the 68HC11
- Depending on the variety, it has built-in
EEPROM,
RAM,
digital I/O, timers,
A/D converter,
PWM generator, and synchronous and asynchronous communications channels
About the 68HC11 continued...
- Is an 8-bit data and a 16-bit address micro-controller
- The 68HC11 includes one new index register, IY, and is 16-bits wide
- Is a CISC micro-controller
- Freescale Inc. now produces this processor
Architecture / Hardware Design
- Is an 8-bit data and a 16-bit address micro-controller
- There are two 8-bit registers, called accumulators, and they are A and B
- The 68HC11 uses these to store variable data
- The return register is accumulator B
- Accumulator A and B are combined to form the 16-bit accumulator D
- Accumulator A represents the high 8 bits of accumulator D
- Accumulator B represents the low 8 bits of accumulator D
Architecture / Hardware Design continued...
- There are four 16-bit registers
- Registers IX, which stands for index register X, and IY can store values
from $0000 to $FFFF (that is, 65535 addresses)
- IX and IY are used as quick-references to memory
- There is nothing to prevent the programmer to use these as extra 'accumulators'
- The other two 16-bit pointers of interest are the Stack Pointer (register SP) and the Program Counter (register PC)
Architecture / Hardware Design continued...
- The architecture of the 68HC11 micro-contoller is very basic.
- There are normally 5 ports, labelled A through E.
- Depending on which model you buy, this may vary. Each port is used for data I/O.
- Port A is used for I/O with the pulse accumulator (timer). Port B and C are used for general I/O. Port D is used
for some general I/O and for special I/O with the SCI.
Port E is used for either general I/O or as inputs to the A/D converter.
Architecture / Hardware Design continued...
- And now, your very own view of the architecture block-diagram:

Programmer's Model
- Again the registers on the 68HC11 are A, B, D, IX, IY, PC, and SP
- Together with those registers, this micro-controller utilizes a facility called condition codes to make
many operations easier (and so it can be used with less memory)
- These condition codes are:
- C - Carry (or Borrow from MSB)
- V - Overflow
- Z - Zero
- N - Negative
- I - I-Interrupt Mask
- H - Half-carry (from bit 3)
- X - X-Interrupt Mask
- S - Stop Disable
Programmer's Model continued...
- When looking at the instruction set, you will find something like this:
Mnemonic Operation Addressing Mode Instruction Bytes Cycles Condition Codes
Prebyte Opcode Operand S X H I N Z V C
======== ========= =============== ======= ====== ======= ===== ====== ===============
ABA Add Accum INH - 1B - 1 2 - - | - | | | |
B to A
(A += B)
BEQ Branch if REL - 27 rr 2 3 - - - - - - - -
= Zero
Where (in condition codes):
- no change
| may or may not change from high to low or low to high
Where (in addressing mode):
INH Inherent (internal)
REL Relative
Where (in operand):
rr Offset relative to the address following the machine code offset byte.
Programmer's Model continued...
- Continuing on with the condition codes: flags may or may not be set
- Consider: ABA
- If acc. A contained (dec) -3 and acc B contained (dec) 3, the Z flag would go from 0 to 1
- Consider the immediate following instruction: BEQ $DEAD
- Then since the Z flag was raised, the PC jumps to address $DEAD
- The assembly looks like this:
* this is an incomplete assembly example -- more is required
LDAA #$FD 0xFD is two's compliment for decimal -3
LDAB #$03 0x03 is, well, you guessed it, decimal 3
ABA Add accumulator B to A, store in A
BEQ $DEAD Jump to $DEAD if the zero flag is set
Programmer's Model continued...
- A picture for you to look at:

Instruction Set
- The 68HC11 micro-controller has 145 instructions
- Most of which can be conjectured based on what you know (but some are hard to figure out)
- The instructions try to do as much as possible in one instruction; this is why there are so many
- Not all instructions have the same width in bits
- An exhaustive list of every instruction would prove to be quite cumbersome
- So I will display just a few of the basic instructions
Instruction Set continued...
- Let us work with accumulator A. To store the constant decimal 5, we would use:
SOMELABEL: LDAA #$05 any words after LDAA <oper> is a comment
- LDAA stands for LoaD Accumulator A, and # represents a constant.
- Without the #, we would be referencing a memory location. Instead, we are referencing the constant 5
- We use $05 because the accumulator A is only 8-bits wide. Syntactically, we could not have used:
SOMELABEL: LDAA #$0005 This is wrong.
Instruction Set continued...
- Now, let us load two constants into accumulators A and B, add them, and store the result into some memory.
LDAA #$06 Load decimal '6' into accumulator A
LDAB #$55 Load decimal '85' into accumulator B
* Note, accumulator D contains the value of unsigned decimal '1621' now.
* Why is this? D can be thought of the concatenation between A and B.
* so D = 0000 0110 0101 0101 (which indeed is 1621)
ABA This stands for Add accumulators B and A and store the result into A
STAA $0101 Store Accumulator A into address $0101 (dec. 257).
* Address $0101 now has the value 0x5B
Instruction Set continued...
- Let's build off of the last example. Add two constants, and store the result into memory if no overflow
occured, otherwise perform an infinite loop:
LDAA #$06 Load decimal '6' into accumulator A
LDAB #$7E Load decimal '126' into accumulator B
ABA This stands for Add accumulators B and A and store the result into A
BVC NOV Branch to NOV if overflow is clear (V is the overflow signal).
FOO: BRA FOO Infinite loop. Branch Always to label FOO.
NOV: STAA $0101 Store Accumulator A into address $0101 (dec. 257).
* Why is this overflow? We are working with signed 8-bit integers!
Demo
- Cue the demo!
- In this demo, I will show you how to compile a C program into HC11 assembly, and run it!
- The program I will demonstrate is Euclid's algorithm for finding the greates common divisor
between two unsigned integers.
- My program can compute the GCD of 600 and 17 in just 1131 clock cycles!
- Is it faster to compute gcd(600, 17) or gcd(600, 13)?
- It is faster to compute gcd(600, 17) due to the mod() function -- it
decrements by 17 faster than it does 13! It takes 1185 clock cycles to compute gcd(600, 13).
Common Uses
- You can use the 68HC11 for anything from microwave ovens to cell phones (ok, maybe old
cell phones.
- The reason why I am interested in this micro-controller, however, is due to the
MicroMouse competition, in which more than
1000 people compete in each years (collegiate)
- Another area of the economy also makes heavy use of the 68HC11. Universities
everywhere use this "simple" processor
to teach their EE/CE students the innerworkings of a basic embedded processor. Our very own
Dr. D. Raskovic taught the EE 444
course this past spring and some of his students used this very controller (or the 68HC12)
in their projects.