My Basket:

Your basket is currently empty.


Click to view the full basket.
cosmetic navigation top arrowview the basket
cosmetic side spacer
PIC vs AVR

We are often asked about this tricky subject, and there is no simple answer because both have their good and bad points. They have been getting closer in functionality over the years and are now quite similar, especially AVR and PIC18F series.



Development Environment

PIC has MPLAB, which is pretty stable (v8.8x) and easy to use, with both assembler and C language. Microchip tools, such as PICkit2 debugger and programmer usually run really nicely from MPLAB. Microchip have launched MPLAB X, which uses Microsoft frameworks. This makes it huge and unwiedly so you will need a fast PC to use it!

AVR has AVRStudio, which has comparable features. We like v4.19, but they have, like Microchip, now moved to AVRStudio6 using Microsoft frameworks as a base, which is enormous (750MB). Jury is out on this, but we have had good reports about it if your PC is new and fast enough. Atmel have dropped support for one of their popular emulators, JTAGICE, in AVRStudio5 and AVStudio6 because too many people were cloning it. Debug tools like AVRDragon can be a bit flaky, but overall work ok.

Verdict: A tie

C Compilers

Both MPLAB and AVRStudio come with integrated free C Compilers, Hitech or CSS for PIC and WINAVR for AVR.

WINAVR is ANSI C, based on GCC compiler, which makes it easy to port code and use standard libraries. Code output is very good, fast and small, partly because AVR was designed for C in the beginning. There is also a free 4KB limited version of IAR C compiler that gives a flavour of professional compilers that cost over $1500.

PIC C compilers struggle a bit more, especially with 16F series, but there are several free ones included in MPLAB. They are not restricted in code size but optimization is limited, so code is not so small and fast as the paid for version. They struggle with portability, but are ok.

Verdict: Just AVR but it is getting closer, especially with PIC18F family.


Assembler

AVR assembly language is very simple, with lots of instructions and the ability to use all 32 registers (more or less) as accumulator. They also have 3 16-bit pointer registers that simplify addressing and word operations.

PIC, especially 16F, assembler is vile, with everything forced to operate through the accumulator. They also make you to use bank switching all the time to access all the Special Function Registers. Although MPLAB includes macros to simplify bank switching, it is a tedious waste of time. The worst aspect though is the lack of branch instructions, just skip and GOTO, which forces you into convoluted structures and spaghetti code.

PIC18F series are much better, although still limited to one accumulator. At least they have got rid of (most) bank switching and included a lot more instructions (70+ instead of 35), with branches and push/pop instructions.

Verdict: Although PIC18F are much better, AVR still wins.


Other features

On price, especially in low volume, they are pretty much the same. Availability of both is usually good but AVR can have periods of long lead times, so for critical production, PIC is better unless you create delivery schedules. Each is available in a variety of packages. Microchip bring out far more versions (constantly), which is both good and bad - trying to keep up is difficult but you can get exactly the chip you need. Latest versions of both AVR and PIC are very low power (for battery use) and have a wide voltage range. Speed of operation is also now very similar. PIC clocks and timers are more accurate.

Microchip have integrated fuse data into their hex file format, so fuses can be set in code. This makes it much easier to transfer projects to production, so a plus for the PIC. On the other hand Atmel have defined 6 and 10-way ISP interfaces, which everyone uses, whereas Microchip haven't, so PIC programmers have to come with flying leads or RJ11 connectors. RJ11 sockets are enormous which makes them difficult to fit on your circuit.

For advanced features, such as integrated USB, CAN and Ethernet, PIC wins hands down, as Atmel have never really got their act together with these features. On the other hand, you can always use external chips, such as FTDI USB to serial chips, Microchip Ethernet controllers or Philips CAN chips.

Low Voltage Operation

Both AVR and PIC have been improved for low voltage operation as battery powered products become more common. AVR microcontrollers are better suited to low voltage operation than the standard PIC16F and PIC18F microcontrollers because these PIC families use a chip erase method that needs at least 4.5V to operate. Below 4.5V, PIC programmers have to use row erase algorithm which cannot erase a locked device. Therefore, in order to run at 3V and use code protection, the PIC ICSP circuit has to be made 5V tolerent so that the programmer can supply above 4.5V for bulk erase. This is quite easily done with protection diodes but it is often forgotten

Later PIC18F microcontrollers, such as PIC18FxxJxx and PIC18FxxKxx are muh better for low voltage operation and J series only operate below 3.3V, so may be a better choice. AVR microcontrollers have also improved and the latest P (pico-power) variants such as ATmega328P are extremely low power. The very latest ATtiny1634 also has improved sleep modes to reduce power consumption when brownout is used, fairly vital with battery operated circuits.

Conclusion

PIC and AVR are both excellent devices for developing cheap and efficient projects. AVR is probably an easier platform on which to learn the basics from scratch. Both have good support networks (forums, code examples etc), but Microchip site wins out over Atmel. Atmel seem determined to make it impossible to find the AVR on their site.

It boils down to what your aim is - there are more robot projects out there using PIC for example. What do you colleagues use, or your company or college, is probably as important a consideration as any other.

In the end, it doesn't matter all that much because learning microcontrollers is like learning a foriegn language - once you have learnt one, learning another is much easier.


PIC and AVR Training Kits

stk200 avr kit picture

AVR Training Kit
stk200 dragon picture

AVR Kit with ICE
PIC starter kit picture

PIC Starter Kit
PIC training kit picture

Complete PIC Training Kit