Home > Multiply Integrated Chordic Keyboard > The Atmel AVR vs the Microchip PIC.

The Atmel AVR vs the Microchip PIC.

February 3rd, 2006 Leave a comment Go to comments

First up: This has been dis­cussed to death on forums and mail groups for a long time. The win­ner is that there isn’t one. The basic truth is that either will do for you a good job. How­ever, I found sub­tle dif­fer­ences between the two that made me end up going with Atmel. Here’s why:

What I needed.

  • Speed I had a project in mind that required an MCU. I tend to be a fairly impa­tient fel­low, and like to see some­thing hap­pen­ing pretty quickly. So I wanted some­thing that gave me a quick devel­op­ment cycle. I also wanted to do C and not futz around in assem­bler, (until I had to opti­mize stuff).
  • Short learn­ing curve I’m an old hand at the clas­sic CPUs 6502, 8051, 8086. How­ever, that was some time ago, and I’ve been out of it for long time. I needed to come up to speed again pretty quick. So I needed some­thing easy on the head.
  • Low cost I didn’t want to have to start shelling out mega bucks for com­pil­ers, assem­blers, yadda, yadda, yadda. I cer­tainly don’t have one of those money trees in my backyard.
  • Linux sup­port What’s this new fan­gled win­dows thingy any­way? :-) Give me a shell anyday.

Microchip PIC

PROs:

  • His­tory: PICs have been around for a long time. Con­se­quently, there’s a huge amount of info on the web, code peo­ple have writ­ten, forums. You name it. A good resource is the piclist.
  • Boot loader: I know, not all PICs are capa­ble of this. But some are, and this is def­i­nitely a PRO. As long as a PIC is self pro­gram­ming, you can chuck a boot loader on it, to ease the pain of devel­op­ment. You don’t need a pro­gram­mer once you have a boot loader present. You sim­ply pro­gram via the UART port of the PIC.
  • Options: This is the big thing I like about PICs. There are a huge amount of options with PICs. A lot more than with the AVRs. You have PICs that can do RF, PWM, timers, A2D, inter­rupts, USB, I2C, coun­ters, etc. I know a lot of these appear in the AVRs as well, but the PICs have a lot more of these options con­tained on each PIC. The PICs, for exam­ple, have the abil­ity to inter­rupt on pin level changes, (basi­cally a glo­ri­fied inter­rupt), but the AVRs only seem to have 2 inter­rupt inputs.
  • Cur­rent drive: The PICs ara really good at dri­ving cur­rent. You can whack an LED straight off an out­put with­out issue.
  • Power sav­ing: The power sav­ing modes are nice on the PICs. You have more options than the AVRs. On some PICs you can slowly down­grade the inter­nal clock, so you could have some code that would increase the clock rate on demand. Also, a lot of PICs can run at 3v, more than the AVRs.

CONs:

  • Pages: PICs can­not address all of it’s I/O space. So, to be able to get to all of it’s reg­is­ters and mem­ory it has to page. It does this with a spe­cial reg­is­ter that is present across all pages, (of course it has to be). This means that yo
    u have to ensure that you are ref­er­enc­ing the cor­rect page. This makes it espe­cially dif­fi­cult when you have inter­rupts going off, as you have to ensure that the old page is set when exit­ing the ISR or just ensure the cor­rect page is set for every memory/register access. To make mat­ters worse, there’s no way of telling what page you’re on! Also, if you want to move data around you are forced to use
    the ‘w’ reg­is­ter. Why?
  • Inter­rupts: PICs do not have vec­tored inter­rupts. This essen­tially means that your code will be more com­plex. Once an inter­rupt has fired, you need to poll all the reg­is­ters to find out who the hell made the noise. This slows things down a LOT.
  • Clock cycles: The exe­cu­tion cycle of a PIC is 1/4 that of the oscil­la­tor speed. This means a PIC run­ning with a 20MHz clock will exe­cute instruc­tions every 200nS, (roughly), and not every 50nS. This one bit me in the bum when I started out.
  • Instruc­tion set: The PICs have a very small instruc­tion set, (35 instruc­tions). They don’t have any com­pare, (huh?), they have very sim­ple branch­ing instruc­tions. Gawd, the has­sle you have to go through just to com­pare two num­bers takes 4 instruc­tions, and bear­ing in mind that each instruc­tion is 1/4 clock fre­quency it all adds up.
  • Lock­ing: You can lock a PIC chip to avoid peo­ple down­load­ing your code. How­ever, once done that’s it! You can’t change it, game over, throw it out if you got it wrong.

Atmel AVR

PROs:

  • No pages: Flat mem­ory model, aaaaah. Nice! No stu­pid pag­ing. Also, reg­is­ters are mapped into mem­ory as well, and they can be addressed as mem­ory or reg­is­ter. Basi­cally it’s all there — some­thing com­pil­ers really like.
  • Inter­rupts: Nice vec­tored inter­rupts. On some of the more recent AVRs, you can also select where you want to place your vectors!
  • Clock cycles: 1 clock cycle is 1 instruc­tion cycle.
  • Instruc­tion set: You have 130 instruc­tions at your dis­posal. Also, com­bined with the mem­ory lay­out aspect, it gives the MCU the feel of a real CPU. Also, (for me that is), the instruc­tion set just felt a lot more complete.
  • Boot loader: The boot loader sup­port is much bet­ter in the AVRs. You can spec­ify a boot sec­tion and lock it out to avoid over­writ­ing. PICs have the lock abil­ity, but you have to spec­ify the whole darn memory.
  • Lock­ing: You can lock an AVR, then erase it, and restart over. Noth­ing is foreever in AVR land.

CONs:

  • Options: There aren’t as many options with AVRs as there are with PICs. It just seems that Microchip have a good sense of which pins to pro­vide what func­tions. It seems to fit nat­u­rally. I found that with my project want­ing to use a par­tic­u­lar func­tion on a pin, but couldn’t because it was being used for some­thing else. I didn’t seem to have that issue with the PICs.
  • Power: Not as many options with power man­age­ment than you have with the PICs. You have less scal­ing options with the inter­nal clock, and most AVRs demand 5v. [UPDATE]: Although now you can get AVRs that can go down to 2.5v!
  • Price: Over­all the AVRs are more pricey than the PICs, although this seems to be changing.

The sum­mary

From the above info my deci­sion was pretty much a no-brainer.

  • The AVRs had the feel of a real risc CPU — real mem­ory space, reg­is­ters, inter­rupt vec­tors, 1 instruc­tion per clock cycle.
  • I could code up in C, and opti­mize in assembler.
  • Pretty much no restric­tions on code space, where to put things, and other bizarre things to con­fuse matters.
  • The boot loader sup­port is really cool.

How­ever, the things I didn’t like with the AVRs:

  • Price — A bit more expensive.
  • Less pin options — Microchip are much bet­ter at func­tion place­ment on pins.
  • All the other CONs I could live with.

No related posts.

  1. No comments yet.
  1. No trackbacks yet.
You must be logged in to post a comment.