President, Seattle Robotics Society
My first robotic project was based on the Intel 8031. It was a fine bit of engineering. I wire wrapped my own controller to its EPROM and support circuits. The motors were two very cheap, 7.5 degree per step stepper motors. The base was built from plywood, as were the wheels, and the motors were so weak it couldn't even carry its own batteries. It did move, however, and could tow its power lead wires around the room. A great accomplishment! I became quite good with the 8051 and derivatives.
The next big leap in my robotic endeavours was my introduction to the Motorola 68HC11. The chip was being used by the MIT 6.270 contest that I participated in back in 1992. This was a major step forward, as the chip was available in a 2k EEPROM version with 512 bytes of RAM. Soon afterward, I joined the Seattle Robotics Society and found a whole group who were working with this excellent chip. It has been the mainstay for our entire group for several years.
As nice as this chip is, it does have a few limitations. A big one has been availability of the E2 version. The other versions have 512bytes of EEPROM, but it is the E2 that really supports single chip mode. It also isn't the fastest processer in the world. Certainly, it holds its own among the 8 bit machines, but more complicated software requires some more horsepower.
Along comes the next big leap! Motorola is already working on the next single chip controller. It is the 68HC12. They have taken some of the great features of the HC11, improved them, and put them atop a new CPU core. This core runs on a faster crystal (currently 16mhz) and runs most instructions faster because the internal clock is 8mhz vs the 2mhz HC11 clock, plus it runs many instructions in only one clock.
In this article, I will describe some of the features that make the HC12 a great chip for robotics. I will do this by comparing features with the HC11. Beware, however, that the HC12 is not just a soup'd up HC11. There is much more to the chip, and making such a simple comparision just isn't fair to the fine engineers at Motorola who obviously put a lot of effort into making the this chip a success. There is an excellent discussion of migrating between the two chips on the Motorola site http://www.mcu.motsps.com/hc12/hc11_hc12.html.
There are still lots of things to learn about the HC12. There are also opportunities to develop some really great tools for the group to use. I have been playing around with this chip for some time now, and am still not an 'expert' yet. The chip is much more complex than the HC11. It is also very flexible.
Lets start by checking out the feature list that Motorola put in their documentation. If you would like your own copies of the spec, look on http://www.mcu.motsps.com/hc12/home.html for more information. You can download both the spec and programmers manual in .PDF format, or order your own copies from Motorola. I recommend downloading the PDF files, since you can search them using Acrobat.
Here is information regarding the 68HC12A4:
There are a set of core features of the 68HC11 that are very useful for robotics. I would like to go through some of the features that make us choose the 68HC11 over other chips, then compare it to the 68HC12.
One of the truly great features of the HC11 is its ability to run in a single chip configuration. This makes for an extremely compact design which uses less power. It also gives the 68HC11 lots of I/O pins. The 68HC12 is also capable of running in single chip mode.
In single chip version, the 1024 bytes of RAM and 4096 bytes of EEPROM are worth their weight in gold. With 1024 bytes, twice what the HC11 provided, you can do some pretty decent processing.
The 4k of EEPROM, compared to 2k on the HC11 is a bit of an understatement. The CPU12 instructions are encoded differently than the HC11. This allows them to pack more functionality into the instructions. Indexed instructions, for example, requires less memory since they are encoded into the instruction byte. The relative size of M68HC11 and CPU12 code has been tested by Motorola. By rewriting several smaller assembly programs from scratch the CPU12 code is typically about 30% smaller. These savings are mostly due to improved indexed addressing.
It is useful to compare the relative sizes of C programs. A C program compiled for the CPU12 is about 30% smaller than the same program compiled for the M68HC11. The difference is largely attributable to better indexing.
A new version, the 68HC12B32 will be available sometime next year and will sport 32K of FLASH memory along with the 1k of RAM. It will be in a 80 pin package, which should prove to be perfect for our robotics work.
The 68HC11 can run in an expanded mode. This allows you to connect external memory and other peripherals to the chip, at the expense of ports B and C (16 lines of I/O). The external address space is 64k long.
The 68HC12 has a very powerful external memory interface. There are Address lines A0-A21 and data lines D0-D15. Through a rather rich (and complex!) set of options, you can choose to have up to about 5mb of memory with a 16-bit wide data bus. It does this with built in bank switching hardware and support for bank switching in some of the instructions.
To reduce hardware requirements you can optionally have a 8 bit data path if you so desire. The chip is very flexible with respect to the memory interface.
The subject of expanded memory on the 68HC12 gets complicated, and I am not sure I understand all of the addressing modes yet. If you are interested, check out chapters 3 and 8 of the A4 tech ref. Needless to say, there is lots of bang for the buck here, though it may get complicated. I will leave investigation of this area up to you.
The 68HC11 has a special mode called bootstrap mode which allows you to download code via the serial port. This is extremely convenient for robot hackers such as ourselves. It requires only a serial port on your PC and a free program to download.
The 68HC12 does NOT have this feature. It does, however, have a special serial interface that allows you to read/write memory. This is called the Background Debug mode which has a single wire interface. This is going to require some special programming hardware. I have developed a programmer for these chips, and it is available for a very reasonable price. See http://www.nwlink.com/~kevinro/bdm.html for details.
The Background Debug Mode has a lot of power that is going to make debugging and programming your projects much easier. I look forward to seeing things develop here.
The instruction set of the 68HC11 is pretty decent and is easy to learn. You will be pleased to know that your investment of time and brain cells is safe. The 68HC12 is 'source code compatible' with the 68HC11. This means that the instruction set is the same or the assembler will automatically convert things for you.
Source code compatible means that you should be able to take the assembler files for the 68HC11 and compile them with the as12.exe, and it should work. The binary images are very different, however. So, don't expect to take the binary images from a 68HC11 and use them on the 68HC12.
If you are at least somewhat at ease with the 68HC11, you should be able to work with the 68HC12 quite easily since the instructions are mostly the same. There are some additional instructions and addressing modes that you might want to check out, such as the movw instruction which can handle memory to memory moves.
Many of us have been using the timer section on the 68HC11 to generate PWM signals for driving servo motors. On the 68HC11, there are 3 input and 4 output timer channels. Each are individually programmable with TOC1 providing a master reset.
On the 68HC12, the timer section has really been beefed up. The standard timer module consists of a 16-bit programmable counter driven by a prescaler. It contains eight complete 16-bit input capture/output compare channels and one 16-bit pulse accumulator. This means you can drive up to 8 servo motors with one chip!
The pulse accumulator is also available by giving up one of the TOC channels.
The A/D converter built into the 68HC11 has been one of the most popular features that keeps the HC12 in the forefront of robotics. The 8 channels are available on PORTE, and can be sampled 4 at a time.
The A/D converter on the 68HC12 is basically the same, though there are result registers for all 8 values. This means you can sample all 8 values without doing the bank switching. To keep compatibility with existing code, it appears that you can still do the 4 channel multiplexed results as well. I would drop that in a hurry, since you code becomes smaller and simpler to use the 8 channel results.
The 68HC11 has a single serial port, and a single SCI port. The maximum speed available has generally been 9600 baud, unless you were able to choose an oddball speed like 31.250K, or 41.666K. This has served us well in the past, but I have found myself often wanting another port.
The 68HC12 has two serial ports and a single SCI port. The onboard UARTs are independently clocked, and can be driven at standard speeds up to 38400, which is good news if you ever wanted to drive your serial port faster.
The SPI port is comparable to the 68HC11, but is capable of running much faster (4 Mbit/S).
One of the really nice qualities of the 68HC11 in single chip mode is the number of I/O pins you are left with. You get PORTA,PORTB,PORTC,PORTD, and PORTE for a whopping 40 pins of I/O
Well, if you thought that was something, the 68HC12 leaves you with all that, plus PORTF, PORTG, PORTH, PORTJ, PORTS, PORTT, and finally PORTAD. The table below shows the port assignments, but as you can see, there is one heck of a lot of I/O (96 pins!).
|Port A||In/Out||General-purpose I/O in single-chip modes. External address bus ADDR[15:8] in expanded modes.|
|Port B||In/Out||General-purpose I/O in single-chip modes. External address bus ADDR[7:0] in expanded modes.|
|Port C||In/Out||General-purpose I/O in single-chip modes. External data bus DA-TA[ 15:8] in expanded wide modes; external data bus DATA[15:8]/ DATA[7:0] in expanded narrow modes.|
|Port D||In/Out||General-purpose I/O in single-chip modes and expanded narrow modes. External data bus DATA[7:0] in expanded wide mode. As key wakeup can cause an interrupt when an input transitions from high to low.|
|Port E||PE[1:0] In
|Mode selection, bus control signals and interrupt service request signals; or general-purpose I/O.|
|Port F||In/Out||Chip select and general-purpose I/O.|
|Port G||In/Out||Memory expansion and general-purpose I/O.|
|Port H||In/Out||Key wakeup and general-purpose I/O, can cause an interrupt when an input transitions from high to low.|
|Port J||In/Out||Key wakeup and general-purpose I/O, can cause an interrupt when an input transitions from high to low or from low to high.|
|Port S||In/Out||Serial communications interface and serial peripheral interface subsystems and general-purpose I/O.|
|Port T||In/Out||Timer system and general-purpose I/O.|
|Port AD||In||Analog-to-digital converter and general-purpose input.|
There are a couple of drawbacks to the 68HC12 that in all honesty I should point out.
First, of course, it isn't available yet! Motorola is working on both the 68HC12/A4 and B32 variations. They should be out first half of 1997. You can get engineering samples, but not the 'real thing'.
The 'A4 comes in a 112 pin Quad Flat Pack, which is a challenge to solder. Marvin Green has created a carrier board for it which works well. It breaks the pins out to a standard .1" grid. While it shouldn't scare you off, it isn't as easy as the 68HC11 to work with mechanically.
The programmer issue also has a draw back. To program the EEPROM or the FLASH, you will need a programmer such as my BDM interface board. Not quite as nice as the serial port interface of the 68HC11 since you need special hardware. However, the extra punch of the CPU is worth the expense.
This new chip is a great step in a great direction. More and more functionality directly applicable to robotics is being packed into a single chip design. When these chips become widely available, you can expect to see some real innovation.
Be sure to grab yourself a copy of the documentation for this chip. If nothing else, it is extremely interesting to read.
Here are links and instructions for getting 68HC12 resources
as12 assembler is available from Karl Lunt, and is the freeware assembler for the HC12 family.
SBasic is Karl Lunts version of BASIC for the 68HC12. This is a good high level language.
Robotic and Microcontrollers Products is my page that allows you to order the SRS 68HC812A4 Development board, as well as my BDM12 interface board, and the new 68HC912B32 development board.
Imagecraft has a great C compiler for the 68HC12. The compiler runs around $150, but is a great bargin if you would like to write software in C for the HC12.
You can get online versions of the 68HC12 documentation from Motorolas website. Here are the files to grab. You can also get printed versions as described below.
CPU12RM-AD Index is an index to a series of .PDF files that create the Motorola CPU12 Reference Manual. This describes the instruction set and programming model for the chip. It is definitely a must have. There is also an Online Version at CPU12RM-AD or http://www.mcu.motsps.com/lit/manuals/cpu12/outline1.html
a4.pdf is the .PDF file of the 68HC812A4 Technical Summary that contains information specific to the 68HC812A4 version of the chip. This is the one with 4k of EEPROM, 1k RAM, and tons of I/O. This explains all of the systems on the chip, where the registers are, etc. You should definitely have one of these if you are using the 68HC812A4.
(250K bytes) is a PDF file with the electrical characteristics of the 68HC812A4. Timing diagrams, electrical capacities and absolutes, accuracies, etc.
b32ts.pdf is the .PDF file of the 68HC912B32 Technical Summary that contains information specific to the 68HC912B32 version of the chip. This is the one with 32k of Flash, 768 bytes EEPROM, 1k RAM, and still lots of I/O. This explains all of the systems on the chip, where the registers are, etc. You should definitely have one of these if you are using the 68HC912B32.
(272K bytes) is a PDF file with the electrical characteristics of the 68HC912B32. Timing diagrams, electrical capacities and absolutes, accuracies, etc.
Motorola will also allow you to order printed documentation online at http://design-net.com/home2/lit_ord.html where you will find a form to fill out your name and address, then a spot on the bottom for document numbers. The following are the documents that you might be interested in
|CPU12RM/AD||The CPU12 Reference Manual (Must Have)|
|MC68HC812A4EC/D||68HC812A4 Electrical Characteristics|
|MC68HC812A4PP/D||68HC812A4 Product Preview (Not worth the effort!)|
|MC68HC812A4TS/D||68HC812A4 Technical Summary (Must Have)|
|MC68HC912B32ECD||68HC912B32 Electrical Characteristics|
|MC68HC912B32PPD||68HC912B32 Product Preview (Not worth the effort!)|
|MC68HC912B32TSD||68HC912B32 Technical Summary (Must Have)