You are on page 1of 5

About the 68HC11 Micro-contoller

Motorola's 68HC11 Micro-controller is an extension, and an overall improvement, of Motorola's 6800 family (built in 1975) of micro-controllers. The 68HC11 is upward compatible with the 6800 processor with an addition of the Y index register. The 68HC11 processor is an 8-bit data, 16-bit address micro-controller. There are many varieties of the 68HC11 micro-controller. Depending on the variety, it has built-in EEPROM 1,RAM, digital I/O, timers, A/D converter, PWM 2 generator, and synchronous and asynchronous communications channels. The 68HC11 processor is also a CISC machine. The instruction set for the 68HC11 processor contain about 145 instructions, 91 of which are new to the 68HC11. These are an extension to the 6800 line of processors. Freescale Inc. now produces this processor.

Architecture / Hardware Design


The 68HC11 is an 8-bit data and 16-bit address processor. This means that it can store, in its data registers, 8-bits of data at a time. It does, however, handle an address space of 16-bits (from 0x0000 to 0xFFFF). There are instructions that can take as both input and output, a 16-bit constant to the 8-bit registers. (i.e., 16-bits divided by 16-bits stored into 8-bits.) 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. The micro-controller is fitted with memory facilities too. Usually, around 8 Kilobytes are reserved for ROM, 512 Bytes of EEPROM, and 256 Bytes of RAM. Aside from memory, there is the CPU (of course!), clock logic, interrupt logic, mode control, an address space, a BUS, parallel I/O from 5 ports, a timer system, and last but not least, the SPI Below you will find a logical block diagram containing the 68HC11's parts, and how they are connected together.

Programmer's Model
The 68HC11 processor has a total of 6 registers (and one 'pseudo' register). They are A, B, IX, IY, PC, SP. The D register is this 'pseudo' register that contains both A (as the most significant bits of D) and B (as the least significant bits of D). You can place values into and read values out of D without ever having to explicitly call A or B, which is why it is this phantom 'pseudo' register. In the programmer's model, it is listed with the registers A and B, but not seperately, as the other registers are listed. Other registers of interest are the two 16-bit registers IX and IY. These 'I' (which stands for Index) registers contain memory addresses, used to store values into and read values from memory. The instruction set of the 68HC11 contains instructions to do complicated things to the IX and IY registers as well. For example, you may want to store the IX register into memory. An instruction to do this might be
STX $0001

where $0001 is the memory address (remember, memory addresses range from $0000 to $FFFF). Also note that $0001 is direct memory rather than through the use of IX. For this example, it would make no sense to do
STX IX

(although, one might want to do that).

Last but not least, the last two registers of interest are the SP and PC registers. Because they are so common, I will not go into detail about them here. While instructions are processing, certain flags raise, might change, or otherwise make no change. These are called the condition codes of the 68HC11. They 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

Below is a diagram of the programmer's model and the condition codes.

Instruction Set
The 68HC11 currently has 145 instructions. An exhaustive list of every instruction would prove to be quite cumbersome, so I will display just a few of the basic instructions. Keep in mind that the 68HC11 instruction set is CISC, which, oddly, is not normal for an embedded CPU or Micro-controller.

Let us work with accumulator (register) 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.

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 * Why is this? D can be thought of the concatenation * so D = 0000 0110 0101 0101 (which indeed is 1621) ABA This stands for Add accumulators B and result into A STAA $0101 Store Accumulator A into address $0101 * Address $0101 now has the value 0x5B

decimal '1621' now. between A and B. A and store the (dec. 257).

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!

Common Uses
By far the most common use for a 68HC11 micro-controller is as a processor for small robots. Most notably, and the very reason why I am interested in this microcontroller, the MicroMouse competition held every year sees a large usage of this micro-controller. There are a myriad of web sites available to detail the process in making a 'mouse' of your very own. 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 in their projects. Of course, you can use this micro-controller for any embedded task that you wish. Just let your wander...

You might also like