FB Twitter Google Plus
My Basket:

Shopping Cart
Your basket is currently empty.


Click to view the full basket.
Search Site

change currency to dollars change currency to pounds sterling change currency to euros
view the basket

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.




Popular Products


STK200 AVR ICE
STK200 ICE Kit picture

Complete training kit for AVR microcontrollers with AVR Dragon ICE and Programmer


Complete PIC Kit
pickit programmer and board

Full training kit with tutorials and modular PIC board and PICKit4 debugger and programmer



Development Environment


PIC has MPLAB X, which is pretty stable (v5.05) and easy to use, with both assembler and C language. Microchip tools, such as PICkit3 debugger and programmer usually run really nicely from MPLAB X. It is much better than the older MPLAB 8.x environment with better debugger integration, a better layout and is much more stable.

AVR has AtmelStudio 7, which has comparable features but it is huge (750MB) as it uses Microsoft frameworks, as does MPLAB X but Atmel Studio is large and clunky. It has lots of extra features like solutions and web access that make it more complicated than it needs to be. We have found that lots of people, especially when using laptops, find it difficult to install and that it runs really badly. They are reverting to the old AVRStudio 4.18 (with service pack 3) as it runs much better and has all the features they need. The older JTAGICE emulator is also supported by AVRStudio 4 but not later versions. Debug tools like AVRDragon work ok in all versions.

Verdict: MPLAB X is far better than AtmelStudio 7.

C Compilers


Both MPLAB and AVRStudio come with integrated free C Compilers, XC8 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.

Microchip have bought out Hi-tech and have launched their own compiler based on it called XC8. This is completely integrated into MPLAB X and works really well. It has many features that make it superior to WinAVR but code tends to be larger because of the structure of the PIC. The free version included is not optimised but paid for versions are available with more optimisation to reduce code size.

Verdict: Just AVR but it is getting much closer.


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 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. Atmel Studio 7 has added Production ELF Files, which include flash, EEPROM and fuse data in one file. ELF files are generally for emulators and a lot of programmers can't read them. All Kanda AVR ISP can load ELF files. Otherwise, there is a free utility that can convert these ELF fuiles into Intel Hex files.

See How to Create Production ELF Files Kanda blog post for more information on them, in new window.

Target Connectors

With target connectors, 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.

Although Atmel were consistantly using first 10-way (5 x 2) then 6-way (3 x2) interfaces, their latest tools, such as AVR ICE, have changed to 10-way 1.27mm (0.05 inch) connectors. These are nice and small but much more expensive than standard 2.54mm (0.1") sockets. Only the expensive versions of AVR ICE come with any adapters, with the basic version, you are on your own!

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 older 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 and the latest PIC16F1xxx are much 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.

Although the AVR has been improved over the years, they are still basically the same. PIC on the other hand, especially PIC16F, have been completely transformed. Most of the code etc available on the web still refers to old PIC16F877 but this is basically obsolete and the latest PIC 16F devices like PIC16F1789 or PIC16F1939 eat them for breakfast - faster, cheaper, more memory and lower power. Our MICRO-X PIC training kit uses PIC16F1789 because it is so much better than older 16F series chips.

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), Microchip have now taken over Atmel and now makes both PIC and AVR. They seem to be running both side by side quite happily and are unlikely to do anything drastic.

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 foreign language - once you have learnt one, learning another is much easier, especially in C.


PIC and AVR Training Kits









      Product News       Special Offers       Sena Products       A-Z Product Index       Manufacturer Index       Software Downloads       Contact