Page 57 - The Art of Designing Embedded Systems
P. 57
44 THE ART OF DESIGNING EMBEDDED SYSTEMS
Think OTP-one-time programmable-or EEROM memory.
Both let you build and test the application without going to expen-
sive masked ROM. Quick to build, quick to bum, and quick to test.
Keep the size of the code in the microcontrollers small. A few
thousand lines is a nice, tractable size that even a single program-
mer working in isolation can create.
Limit dependencies. One beautiful benefit of partitioning code into
controllers is that you’re pin-limited-the handful of pins on the
chips acts as a natural barrier to complex communications and in-
teraction between processors. Don’t defeat this by layering a
hideous communications scheme on top of an elegant design.
Communications is always a headache in multiple-processor appli-
cations. Building a reliable parallel comm scheme beats Freddy Krueger
for a nightmare any day. Instead, use a standard, simple protocol such
as I’C. This is a two-wire serial protocol supported directly by many
controllers. It’s multi-master and multi-slave, so you can hang many
processors on one pair of 12C wires. With rates to 1 Mb/sec, there’s enough
speed for most applications. Even better: you can steal the code from
Microchip’s and National Semiconductor’s Web sites.
The hardware designers will object to adding processors, of course.
Just as firmware folks take pride in producing optimum code, our hardware
brethren, too, want an elegant, minimalist creation where there’s enough
logic to make the thing work, but nothing more. Adding hardware-which
has a cost-just to simplify the code seems like a terrible waste of
resources.
Yet we’ve been designing systems with extra hardware for decades.
There’s no reason we couldn’t build a software implementation of a
UART. “Bit banging” software has been around for years. Instead, most of
the time we’ll add the UART device to eliminate the nasty, inefficient
software solution.
One of Xerox’s copiers is a monster of a machine that does
everything but change the baby. An older design, it uses seven 8085s
tied together with a simple proprietary network. One handles the
paper mechanism, another the user interface, yet another error pro-
cessing. The boards are all pretty much the same, and no ROM ex-
ceeds 32k. The machine is amazingly complex and feature-rich . . .
but code sizes are tiny.

