Embedded Development: A Personal Journey

How does one get started with embedded development? Until recently, I never realized how simple it is today.

With Makers Faire, Arduino and the Internet - Hobbyists have never had it better. It seems like anyone with a basic knowledge of C and electronics can today do what once was the purview of electrical engineers. For me, as a decade plus C/C++ veteran comfortable with writing low-level software, this discovery came relatively late in my professional career. And I always had a dreamer's interest in creating machines. So with my multimeter, breadboard and wires in hand, I'm throwing my hat into the ring.

Better late than never I guess.

A final note before continuing - this is not an introduction to basic electronics or the Arduino. There are plenty of tutorials and articles out there about using the Arduino. And for most projects a basic understanding of electronics, an Arduino and the associated programming software for it is all you need. My focus is on taking that basic knowledge and creating a product, a collection of circuits and components into systems, which in turn are pieced together, resulting in a product.

The Idea

Let's start with a "simple" idea: creating a 16-bit personal computer. Late 80s, early 90s technology isn't going to impress your average consumer - but it's something I can wrap my head around for a starter project.

First, it's not all that simple of a project if you're just starting out with embedded development. It requires learning just about every aspect of basic electronics, machine architecture, I/O, etc. But you'll find all you need to build such a thing relatively cheaply from any online electronics supplier. And being an old technology there's plenty of literature out there to help if you ever get stuck.

You'll need a good understanding of circuit theory, a few ICs, some assembly programming skill, a display mechanism (lights, LCDs, maybe even VGA display?) And then you have to think about keyboard input.

All of this can seem daunting. The skills to create all of this takes time to develop. So, as goes with any starting project, start simple and small, and build up.

Considerations

Again, I'm not writing an article to teach basic circuit theory. Check out this link if you're trying to learn the basics. Understanding voltage, current and resistance is essential if you're going to work on anything beyond simple Arduino starter projects. Without this understanding, you won't know why, despite being connected to a power source, your LED isn't lit, or even more important, why your green LED is now yellow (overloaded) or even blown out. And finally, you have a working circuit, only that it quickly drains your power source. So not only do your circuits have to work, they need to work with low-voltage, low-current sources like a 9V battery, or a USB connection.

These considerations are multiplied a hundred times when creating a seemingly simple product like a 16-bit computer.

First Steps

Design is essential when creating a product. At the moment I don't really care if the end device is just a bunch of breadboards wired together as long as it works. By design, I mean simply - what exactly are you trying to make.

Any device consists of multiple systems working together to give everyday users the ability to input commands, and to receive feedback (output) from those commands. A PC is simply this concept scaled up. So let's start with the lowest-level circuit for our PC - the CPU.

Cheating a bit

First, my plan is to not use an Arduino in my design. Some consider Arduinos a cheat - a ready made solution that simplifies creating so-called "smart" devices. They're a great way to quickly bring a physical product idea to life. But if you're really trying to learn the innards of embedded devices, it helps to work a bit under the hood. This approach helps immensely I think when working with non Arduino based systems.

Instead let's pick a CPU architecture and work from there.

CPUs are collections of thousands of circuits. A CPU is essential when developing any computing device. One step above the CPU is the "MPU", or the Micro Processing Unit (MPU.) MPUs typically have memory for storing programs, a CPU for running programs, and a couple other components like a clock and supporting circuits. An MPU could be a board, like an Arduino, or an integrated circuit (those black boxes with pins.) An Arduino is actually a circuit board supporting an Atmel MPU - so in a way it's one step above traditional MPUs, but still not complete enough to be a complete PC.

Okay, enough summary. We're making a PC, and the next step is to choose an underlying architecture.

The 65816

Back to the CPU - my choice is the 65816. What the heck is that? And why the 65816 versus the 16-bit 80x86, or some other well-known architecture?

The 65xxx "family" of processors is best known as the one used by the original Apple home computer line. I learned how to program with an Apple IIe - not just BASIC but also assembler. Even today though I haven't touched the 65xxx line since the 80s, I can almost write 6502 assembler without a reference.

; Draw a line of 7 white pixels onto the upper left of the screen ; (assuming we've switched to hires mode.)
PHA          ; Push accumulator to stack  
LDA #$00     ; Set accumulator to 0  
TAX          ; Move accumulator to X register  
LDA #$ff     ; Load 255 into accumulator  
STA $2000,X  ; Store accumulator into memory at address 0x2000+X  
PLA          ; Pull from stack value and set to accumulator  

The 65816 was the 16-bit version of the 6502, used in the Apple IIgs and the Super Nintendo Entertainment System. While 16-bit internally, the 65816 accessed memory on an 8-bit bus. Some other interesting tidbits about these old processors make them quite simple to tinker with on a breadboard. I'll go into these quirks in later articles.

Okay that's enough summary for now. Up next: the tools I need to get started.