The Processor: AVR Mega128

68hc11 is the standard

The original system used a Motorola 68hc11 processor. If you've never used one, it is truly a delight. Classy and easy to use peripherals, decent (8 bit) A/D, and available in one chip or multi-chip when more memory is needed. It dealt with C compilers pretty well. After trying several free compilers, I finally settled on Dunfield's Micro-C, a good 68hc11 compiler for $99.  I pretty much wrote my last lines of assembler about 10 years ago. With a decent cross compiler, and a processor that is efficient at running C, I find little use for assembler any more.

Unfortunately the 68hc11 has pretty much run out of steam due to its 70's 6800 architecture. It's OK at running C, but not the best. It also can only support 64K total memory: code plus data plus EEPROM plus I/O,  (without paging tricks). That was plenty for BoatBus I. But I wanted a bit more performance and memory this time. 68HC12 looks good, but I added up all the cost for development tools, and saw that it didn't give a quantum jump in performance.

Rabbit / Z80s

Rabbit PrototypeI've used Z80's a bunch in the past, so the Rabbit 2000 (now 3000)  was appealing. The Rabbit processor is basically a Z80 on steroids. Lots of memory in an 8 bit processor, about 4-10X the performance of the 68hc11, and decent, low cost development tools.  I paid $139 for my first eval board and their Dynamic C compiler.  The Rabbit 2000 processor sports 22MHz clock, fewer clocks per instruction, lots of I/O, and external RAM (128KB usually) and Flash. Their clever bootstrap can boot up a bare flash chip using nothing more than a serial port. All in all it was a decent experience. But the proto I bought was hard to tie hardware to since it uses 2mm headers which can't be wire-wrapped. So I wire-wrapped up a processor (photo below) from scratch. It takes three chips (CPU, RAM , FLASH) to do the core, plus a $30 QFP adapter. They don't offer a single-chip version with memory on chip. Instead they sell little modules. But chips are generally cheaper than modules with multiple chips. After using the 68hc11, I didn't like the Rabbit peripherals. No on-chip A/D, and every time I wrote code for some I/O device, there was some big hack required. Their Real Time Clock required reading the registers twice to see if the time changed between reads. Ugh. And their SPI is really just a synchronous UART: it has the bits reversed from normal SPI!  To correct this requires code to test and set each bit in the data byte. Why not just write the SPI by banging the bits myself? Their C I/O routines are pretty slow, executing a handful of instructions just to set or clear a bit. Also their compiler isn't really C. It doesn't know about basic stuff like #include. Dynamic C is C-like, but not C. One big strength of Rabbit is their support of Ethernet, Compact Flash, four or more UARTs, etc. Their 3000 has improved things, and the new 4000 has on-chip ethernet. Still not a single chip, still no A/D.

Atmel AVR

So I kept looking for the right processor. Single chip, but with a range of I/O and performance, and expandable to external memory and I/O, good peripherals, lots of Flash and RAM. Nice cheap but good development tools.  Meanwhile a buddy asked me to design a new product for him. I'd been looking at all the processors out there, and the Atmel AVR looked good. Circuit Cellar contributors liked it, and the tools looked decent. I bought a $29 AVR-ISP dongle, a couple of AT8535 chips from Digikey, wire-wrapped up the chip, and downloaded the GNU C and AVR Studio and was in business. I had some trouble getting GNU C working, and since my client was footing the bill, I bought the ImageCraft ICC compiler ( for $199. Then later  upgraded to the Pro version for another $300. It is an excellent tool. The Pro version is only needed if you really need to optimize another 10% out of your code. But with the Mega128, there is lots of code space. The on-chip peripherals are awesome, stolen from the 68hc11, I suspect. The processor screams since it access a 16 bit instruction and 8 bit RAM every clock cycle: 8MHz is 8 MIPS, and 16MHz is the max. The memory mapped I/O is so fast that I find I often need to insert no-op delays to slow things down. PORTA = 0x42 takes two clock cycles. The best part is that the architecture was designed from the ground up to run compiled C fast and efficient, unlike most other architectures. The tools including the Atmel AVR Studio Debugger are great. I started with the AT8535 and worked my way up to the Mega-128. What an amazing chip for $15 (Qty. 1 from Digikey). It still takes a QFP adapter to prototype one, but several good adapters are available (see below). Another great AVR resource is  since they have tons of pointers to resources, a great 'web ring', and newsgroups to answer my questions.

The Mega-128 is overkill for low end controllers. Atmel's next step down is the Mega-64 (same I/O and pinout, less memory) and the Mega-32/16 (44 pins, less FLASH and RAM, and one UART). I figure all that extra stuff is worth the $15 vs $8. Since I use one UART for RS-485 on most systems, the second is still available as a debug port.

I splurged $40 on a tiny JTAG ICE from ECROS Technology. It's called the "AVR Ice Cube" You can see it in the photo. Having the ability to do source code debug on an embedded system is great. Getting it for $40: priceless.

Lately I have begun another lower-end AVR project. The 32 pin Mega 48/88/168 is an amazing processor for about $3-4. Up to 20MHz clock, 8MHz internal oscillator accurate enough for serial baud rates. The 32TQFP is a tiny package but at 0.8mm pitch humans can actually solder it. They are also available in a proto-friendly 28 pin skinny-dip. They can be programmed and debugged over the one wire DebugWire interface. The AVR Dragon ($49) will do this, plus the regular 10 pin JTAG, 10 and 6 pin ISP. All via USB. What will they think of next.

I have also begin using the free WinAVR gnu-C development tool. They have made it a bit easier to use with a new IDE, and added some very god examples. I like it.


A former employer uses PIC processors where a low-end embedded controller is called for, with many legacy designs. THey are not the only PIC fans. PICs are comparable to AVRs. However they use 4 clocks per instruction, slightly less elegant I/O, and their architecture slowly evolved up from a minimal assembly instruction set on tiny processors with the instruction set designed to run hand-coded applications, not designed from the top-down to run C efficiently. When PICs first came out years ago, they had no peripherals (timers, interrupts, UARTS, etc.) and they expected you to create them all in firmware using their clever assembly code. Coming from the 68hc11 world, it was a big step backwards to do crazy stuff like this. Cleverly designed peripherals don't use up that many logic gates, and are critical for managing tight I/O timing requirements. Microchip evolved to supporting lots of peripherals, just like everyone else. Also Microchip started life with one-time-programmable (OTP) and mask ROM technology and then evolved to Flash. Atmel started out as a top-notch Flash memory company, and clearly Flash is a key technology for processors. Anyone can build CMOS chips with just logic. But like any old low-end processor architecture designed for hand coding: PIC, 8051, 68hc05, they have gotten faster and can run C, but not as efficiently. So I like Atmel AVR. I think Atmel got everything right.

Another subtle difference between PIC and Atmel AVR: I've designed several products and projects with AVR, and have never needed to call tech support (yet!). Their tools are good and cheap, or free, and they work. Their documentation is high quality and their chips work. At work the PIC applications guy was there pretty regularly to address tool and other problems. However I hear from folks who do need Atmel support that it can be hard to come by whereas Microchip is very willing to help. I'd be interested to hear from others regarding their experiences with the two vendors.

Here's a photo of the proto of the AVR Mega128 processor with an LC10X type LCD controller. The empty sockets on the top left are from the old 68hc11, SRAM and EPROM that I removed. The Mega128 is on a prototype adapter from  This cool adapter takes any .8mm or 0.5mm QFP up to 80 pins. $8-10 each plus shipping. In the upper right are the LCD controller FPGA,  8 pin config EEPROM, and display RAM . The IC and caps on the right are the V- power supply for the LCD. JTAG ICECube is lower right.  I had planned to use the  32KB SRAM because I wasn't sure all that graphics and communications code would fit in the processor's 4KB, but it's running fine with RAM to spare.

BoatBus Home
BoatBus Story
Weather Node
LCDs are a pain. but fun!
AVR Processors
Communications via RS485
Prototyping, and the Lab
Last Updated: May 20, 2005