The 8-bit Microcontroller Is Still a Great Option for Low-Power and Ease of Use
Back during the 1990’s, what I call The Golden Age of Microcontrollers, C compilers were just becoming popular, but programming in assembly was still required if you wanted a job in embedded programming. Field applications engineers (FAEs) like myself would do customer visits, standing in front of a room of wide-eyed engineers, all munching on the donuts I’d brought as I breathlessly extolled the virtues of my latest microcontroller offering.
Back then semiconductor companies weren’t minting new microcontrollers every month like today. We usually brought one or two new ones to market every quarter. But still, some things never changed. The two dozen engineers I was entertaining that day with my deft PowerPoint magic belonged to a group that built automotive body controllers. Body controllers were simple little boxes that operated under the principles of goesintas/goesoutas, as in the switch signals “goesinta” the box and the actuator control signals “goesouta” the box. Simple stuff for an 8-bit microcontroller with lots of GPIO.
It was your standard dog-and-pony show until a hand went up from the back of the room.
A strong-willed voice said, “Management has decided we need to start using 32-bit microcontrollers for body controllers.” From the murmurs in the room I guessed that management hadn’t decided anything like that and maybe this person had an agenda, such as a favored supplier that sadly, tragically, wasn’t mine.
“You don’t need a 32-bit microcontroller and I don’t believe you,” I said in an alternate universe. In this universe what I actually said was a more career-safe: “Can you tell me what features in a 32-bit architecture you need for your next generation controllers?”
A pause followed, and he responded somewhat defiantly “We just need 32-bit.” There was hesitation in his voice. The other engineers, sensing his weakness, eagerly turned to the front of the room to hear my response.
I carefully explained the advantages of a 32-bit architecture over 8-bit. Did they need a faster clock speed? Was the next generation product performing more complex math? Was the firmware going to be multithreaded, and did it need a real-time operating system (RTOS)? Was the firmware size going to balloon to the point where they needed increased memory addressing? All of these were, and still are, valid reasons for making the leap from an 8-bit to a 32-bit core (16-bit is the sweet spot in between, but that’s another story).
What followed was an enjoyable donut-filled discussion on the architecture differences between 8-bit and 32-bit. The 8-bit microcontroller architecture is simpler and has an easy to understand programming model. It usually needs just a single supply. Despite marketing claims to the contrary, modern 8-bit architectures are lower power compared to 32-bit because the innards toggle fewer bus signals.
Real-world 8-bitter example
Microchip Technology has been proud of its offering of 8-bit microcontrollers for years. The popular Microchip megaAVR 8-bit core (also called the ATMega) has a conventional Harvard architecture that can address up to 256 Kilobytes (Kbytes) of program memory. It uses a simple register-based architecture that is very C-friendly with 32 8-bit general purpose (GP) registers (Figure 1).
Figure 1: The megaAVR microcontroller is based on 32 8-bit registers designated R0 to R31. The registers can also be addressed as register pairs to form sixteen 16-bit registers. (Image source: Microchip Technology)
GP registers can be doubled up as register pairs to form sixteen 16-bit registers. The last three register pairs can optionally be used as 16-bit address registers X, Y, and Z for indirect addressing.
Other than these GP registers, the megaAVR has a 16-bit stack register and an 8-bit status register. That’s it. Simple enough to program in assembly (“Real Programmers Program in Assembly”).
No, you cannot access the program counter in the megaAVR. Leave it alone.
A typical example of the megaAVR family is the 20 megahertz (MHz) ATMEGA1609. It’s an easy-to-use microcontroller with 16 Kbytes of flash, 2 Kbytes of RAM, and 256 bytes of EEPROM. Most instructions are single-cycle.
Figure 2: The Microchip Technology ATMEGA1609 is a simple, flexible, low-power 8-bit microcontroller that can operate in a wide range of environments. (Image source: Microchip technology)
It has a 10-bit analog-to-digital converter (ADC), five 16-bit timers, a real-time clock (RTC), multiple low power options, and a 2-cycle signed/unsigned hardware multiplier.
The megaAVR also has single-cycle bit set and bit clear instructions, as well as bit test instructions that need from one to three cycles.
The importance of bit instructions is often overlooked by developers that have a deep love affair with the C language. Truth is, native bit instructions (“We don’t need no ATOMIC instruction”) can dramatically increase performance, reduce code size, improve code readability, and clear up your complexion.
Power supply needs for the ATMEGA1609 are a flexible 1.8 to 5.5 volts that can operate over -40°C to +125°C. The wide power supply and operating temperatures are most definitely not by accident. By design, this 8-bit microcontroller is designed to adapt to, and be used in, a wide range of design environments. “Ease of Use” strikes again!
Sometimes a developer just has to get a simple project done fast; 8-bitters are easy to use, flexible, and tough as nails. These characteristics are tough to ignore.