Al Williams

Dr. Dobb's Bloggers

Draft PIC

December 15, 2009

I seem to be less partisan than most people I encounter in this industry. I personally like coding in C and maybe C++. I don't mind doing assembler. But I've written books and columns about Java. And I speak maybe a handful of other languages fluently and I use each where it is most suitable. Carpenters don't just use hammers and so I like to have a full toolbox. Same goes for processors. I've used dozens. My early work was with 1802s, 6805s, and Z80s, but I've worked on processors ranging from the 68000s I used to take apart under a microscope to more modern TI DSP chips. Just don't ask me about vi versus emacs (because, after all, emacs is the One True Editor).

I seem to be less partisan than most people I encounter in this industry. I personally like coding in C and maybe C++. I don't mind doing assembler. But I've written books and columns about Java. And I speak maybe a handful of other languages fluently and I use each where it is most suitable. Carpenters don't just use hammers and so I like to have a full toolbox. Same goes for processors. I've used dozens. My early work was with 1802s, 6805s, and Z80s, but I've worked on processors ranging from the 68000s I used to take apart under a microscope to more modern TI DSP chips. Just don't ask me about vi versus emacs (because, after all, emacs is the One True Editor).

These days I seem to have settled on a small number of CPUs. I tend to use one of a few ARM processors for bigger projects or even one offs. The price is pretty low and the power of these processors is good. For simple things, though I tend to use Atmel's AVR series or Microchip PIC. You'd think one or the other would be good enough, but I can't seem to make up my mind.

I have a love/hate relationship with the Microchip PIC that goes back many years. The PIC16 architecture is awkward and convoluted. The mapping to a C compiler is strained at best. The memory banking and poor stack is a constant waste of time. Granted, the 18F family and some of the newer offerings are much better (especially with regard to mapping to C). Yet a lot of people—me included—still use the PIC16F family. Why?

There's a lot of reasons, I suppose. First, if you are making many devices, the PICs are cheap. And they get cheaper all the time. They are also available. I can't think of one time I've went to order PICs and were unable to get them almost immediately in any quantity. The development tools are cheap (I noticed Microchip wants to replace my ICD2 with their new PICkit 3 for US$70.00; not a bad price for what amounts to a low-end hardware emulator).

But I think the one thing that keeps me going back to Microchip is that they seem to understand that I don't want to redesign everything each time they have a new idea. If I have a socket on my PC board for a PIC, it is a good bet that just about any PIC with the same number of pins will fit in that socket. Every time I notice the price creeping up on a PIC, I look and sure enough its because they “replaced” it with a new part that fits in the same socket, has lots more of everything, and costs 40% less than the old part at its cheapest point. Sometimes it takes a change or two in the code and sometimes it doesn't even take that unless I want to use a new feature.

I've had PIC designs that have migrated to 4 different PIC processors over their lifespan and none of them have required any hardware changes. As a hardware guy I like that. As a software guy, I like the Atmel chips. The GNU C compiler support is great and the assembly suits me better (even though the restrictions on register usage is sometimes arbitrary). But there are times I can't get certain AVR parts. New AVR parts are unlikely to fit in my old socket. At least that's been my experience.

What I don't understand is all the “one off” projects that use PICs. If I am going to build a one off device for some control application, I don't mind spending the extra $10 for a 32-bit board. Or I might buy something like a Basic Stamp or even a small PC/104 board. If I can save 2 or 3 hours of development time, it pays for almost any small board I can find. At the very least, I'll use the AVR where I have a reasonable (and free) C compiler.

You can learn more about the PICkit 3 at http://www.microchip.com/pickit3/. If I put my hands on one during the new year, I'll review it here. Hopefully it will have an interface to the One True Editor.

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task.
However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

Video

This month's Dr. Dobb's Journal

This month,
Dr. Dobb's Journal is devoted to mobile programming. We introduce you to Apple's new Swift programming language, discuss the perils of being the third-most-popular mobile platform, revisit SQLite on Android
, and much more!