Computers & Mobile Maker News Technology

Sega vs. Nintendo, Mac vs. PC, Android vs. iOS… the tech industry has spawned its fair share of “holy wars” in our time. But there’s one that’s had Makers and embedded engineers up in arms since the nineties — the war of the 8-bit microcontrollers: Microchip’s PIC vs. Atmel’s AVR.

With Wednesday’s announcement that Microchip will purchase Atmel for $3.56 billion, is the war finally over? What does this mean for the future of embedded development?

Probably not much in the short term. Microchip and Atmel will continue to produce and provide support for their existing devices well into the future, since, well, they’re in everything. In your home, in your car, in your pocket — Microchip has shipped over 12 billion PICs to date, and the Atmel megaAVR is the chip that powered the first Arduino, which introduced scores of Makers to the world of physical computing.

There’s a lot of promise here though. Microchip/Atmel have the the opportunity to combine the best of the AVR and PIC worlds into an awesome microcontroller platform. Despite the growing popularity and decreasing cost of powerful 32-bit ARM chips, there are still plenty of applications where 8 bits are all you need.

So what are the differences between PIC and AVR, and do they even matter? If you’re just starting out in the world of embedded software, you’re probably good to go with an Arduino board and its easy-to-use tools. But when you want to take the next step — turning your prototype into a production-ready device, or building timing-critical applications — you’ll have to make a choice.

AVR: Open Source, Maker Friendly


If you’ve used an Arduino before, you’ve already programmed the AVR — it’s in the Uno, Pro, Mega, Gemma, LilyPad, Leonardo, Diecimilia, Duemilanove, and more. It’s popular with Makers because it’s been embraced by the open-source community. If you want to get started with standalone AVR programming, all the tools you need are available for free, for all operating systems. AVR-GCC is a full-featured and well-supported C compiler (if you use a Mac, setup is as easy as installing CrossPack), and the AVRDUDE utility lets you upload your code to an AVR microcontroller using one of many programming devices like Atmel’s official AVRISP mkII or Sparkfun’s Pocket AVR Programmer.

The “R” in AVR stands for RISC: reduced instruction set computing. What that means is that if you ever want to get your hands dirty with some assembly language, you’re gonna have a blast. The instruction set is both well-suited for C compilers and straightforward enough to allow hand-coding of time-constrained routines. There’s a sizable number of awesome AVR projects out there that do amazing stuff with assembly language: Linus “lft” Åkesson’s Craft, Phasor, and Bitbanger demo boards, the Uzebox game console, and my own Terminalscope project that can let you browse the web on your oscilloscope.

Unfortunately, where the AVR falls short is in bang for your buck. The ATmega328P, heart of the Arduino Uno, costs $3.70 for a breadboardable DIP package. This gets you 32K of ROM for your code, 2K of RAM, and 23 I/O pins: six of which can be used to read analog voltages, and six of which can output PWM signals for driving motors or fading LEDs. If you want more pins or more memory — say, 16K of RAM and 32 I/O pins, in a 40 pin DIP package — you’ll have to upgrade to the ATmega1284, which will run you a whopping $7.67! If you’re OK with surface-mount soldering, there are cheaper options with more exotic peripherals like onboard USB, but you’ll find similar parts from other manufacturers at a tiny sliver of that price.

“There’s a PIC for that”


Before Arduino, the Microchip PIC was the chip of choice for hobbyists and professionals alike. Their product lineup is huge, they’re packed with peripherals, and they’re dirt cheap. Want 28 analog input channels in a DIP package? The PIC16F1717 is $2. Want to make something cool that talks to your computer over USB? PIC16F1454, $1.40, no extra components needed!

Microchip has put some pretty interesting peripherals in their PICs that can reduce or eliminate the need for external components, potentially reducing costs further. Many have onboard digital-to-analog converters (DACs) for generating true analog output voltages. The Complementary Waveform Generator can simplify driving of DC motors. And the Configurable Logic Cell is kind of like a tiny FPGA: it can perform simple operations (AND, OR, XOR, and more) on input signals and route them to outputs without any intervention from the main processor — even in sleep mode.

So PICs are dirt cheap, widely available, and have plenty of cool stuff on board — what’s the downside? Why was it the AVR that rose to megastardom in the Maker microcontroller revolution of the mid-2000s and not the PIC? Many would say that it’s the tools. While there are numerous free and open-source tools out there for AVR development, if you want to program PICs, you’re gonna need to use Microchip’s software and hardware.

Until a few years ago, this restricted PIC development to Windows users only. Microchip’s current integrated development environment (IDE), MPLAB X, is built on the NetBeans platform, and runs on Windows, OS X, and Linux. The download is a hefty 500+ MB. The user interface can be daunting, with its array of toolbars, sidebars, and configuration dialogs. If you’re more of the command-line type, it’s possible to use a script buried deep inside the MPLAB X app bundle to upload code to your chip.

Unlike the AVR’s clean RISC architecture, the PIC’s memory is segmented into banks of 128 bytes, only one of which can be active at a time. This arrangement has hindered the development of open-source compilers. The Small Device C Compiler is the only one that I’m aware of. I’ve used it to produce working results, but it may not support all features of the latest chips, and has some bugs. If you want to program a PIC in C, your only other option is Microchip’s XC8 compiler. The free version doesn’t perform any optimization on your code: if you want to build the fastest code possible, you’ll need to buy a Pro license, which will set you back a thousand bucks. A justifiable expense for a professional engineer that’s shipping a million devices, but sadly out of range for most hobbyists.

As far as device programmers go, the PICkit 3 ($50) is the only device guaranteed to support the latest PIC models. They can be tricky to set up (mine wouldn’t work with my Mac out of the box, and I had to use a Windows PC to upgrade its firmware) but do the job just fine.

The Future

I’m dreaming of Microchip/Atmel releasing a new generation of microcontroller with the AVR architecture, open-source toolchain, and the PIC’s wide selection of peripherals and low price — but is it too late? 32-bit ARM Cortex-M devices, such as those in the Teensy and Arduino Due, are poised to take over the low-end market, and full-featured Linux systems like the Raspberry Pi Zero and CHIP can be bought for a handful of dollars. But there’s something to be said for the sheer simplicity of the 8-bit micro. You can learn everything there is to know about one in a few weeks. Squeezing every last drop of performance out of a chip — counting clock cycles, writing hand-tuned assembly language, slicing off instructions to get your code to fit on a cheaper part — these are what keep me and countless other hackers excited about embedded development.

Matt Sarnoff

Matt Sarnoff is the lead firmware engineer at Glowforge. He's been tinkering with microcontrollers large and small for nearly ten years.

View more articles by Matt Sarnoff