I have worked with PIC16 and PIC18s for over three years now and would like to get to know AVR as well. I have no specific project in mind, but would like to try around with the different architectures. I'd like to get a compatibility report on PIC and AVR.

uC's software
I am familiar with Assembly and C for PIC16 and PIC18. How do the Assembly and C variants for AVR microcontrollers vary from the PIC variants? Are there a lot differences?

PC's software
What software would I need to compile and assemble my programs for AVR chips? Is it free and where can I download it?

Programming hardware
I've used VOTI's Wisp648 to program PICs, but that board can't program AVRs. Do I have to buy a programmer or are there any circuits available on the web that I can build myself?

uC's hardware
For PICs, I have used the PIC18F4620 a lot. I'm looking for an AVR with similar features. The features I like are:

  • Internal Oscillator
  • Timers
  • 5V and 3.3V version
  • ADC
  • MSSP with I2C and SPI support
  • (E)USART
  • PWM
  • Much I/O pins
  • >= 32kB program memory, >= 2kB RAM
  • DIP package

What AVR chip would have the same features? The package is a deal breaker, I really want DIP, PDIP or SPDIP. What would an AVR with comparable features be?

SPI and I2C variants
I was told that Microchip has its own variants on the SPI and I2C protocol. I often use SPI and I2C slave devices from microchip in combination with a PIC. Would I be able to use these chips (23K256, RTC, ENC28J60, ...), in combination with an AVR? In addition to that, would it be possible to link an AVR and a PIC chip using I2C or SPI?

  • \$\begingroup\$ @LeonHeller sorry I wasn't clear, I don't have a specific project in mind, but would like to play around a bit to get to know the different architecture. \$\endgroup\$
    – user17592
    Apr 23, 2013 at 11:11
  • 5
    \$\begingroup\$ This is question is too broad and not a good fit for our Q+A format, but in general you read the data sheets of the processors you are considering using. I don't know what it's like on the Dark Side, but Atmel probably has a selector guide like Microchip does. These companies have too many micros for anyone to keep in mind. I've done well over 100 PIC projects over 15 years professionally, but still consult the selector guide when picking a new one. \$\endgroup\$ Apr 23, 2013 at 12:14
  • 1
    \$\begingroup\$ What kind of instruction set AVR's use, and development tools, and so on, are easily researched. These things are well supported, like PIC. I recommend this entertaining video: youtube.com/watch?v=DBftApUQ8QI \$\endgroup\$
    – Kaz
    Apr 23, 2013 at 15:17
  • \$\begingroup\$ Take a look at electronics.stackexchange.com/a/66163/8627 and change Linux for Windows. The toolchain is largely the same. Not identical, but full of things to Google for. \$\endgroup\$
    – jippie
    Apr 23, 2013 at 19:08
  • \$\begingroup\$ @jippie nice! Saved in my bookmark for when my samples have arrived :) \$\endgroup\$
    – user17592
    Apr 23, 2013 at 19:10

3 Answers 3


uC's software

The PIC and AVR instruction sets are similar, but I would not start out programming an AVR in assembly. Program in C, with Atmel Studio. It comes packaged with the AVR version of gcc, and has a really good disassembler that shows you the line of C you wrote, and under it, the resulting assembly instructions, very handy. I would also download WinAVR.

PC's software

Use Atmel Studio. Don't bother with Eclipse, Programmer's Notepad, or whatever other random IDEs people use. Atmel Studio is based on Visual Studio, has all kinds of plug ins available from Atmel, and has a good simulator built in.

Programming hardware

There are lots of cheap AVR programmers, such as the Bus Pirate, but get an Atmel ICSP. It is entirely worth the extra expense if you intend to do more than one AVR project. It uses USB, and is controllable from inside Atmel Studio.

uC's hardware

There is a selector tool, but in general, low end AtMega typical hardware is:

Internal Oscillator (8 MHz)
3 Timers
2.7-5.5V Supply range
8-channel multiplexed ADC
I2C and SPI support
2 PWMs that work in conjunction with the 8 bit timers

Going to higher performing chips will buy you more timers and PWMs. How much flash memory and SRAM you have available depends on the particular chip. Most of the AtMega parts parts are available in PDIP, with the really high pin count stuff being QFP.

SPI and I2C variants

It is possible to use MCP I2C (TWI for AVR) and SPI devices with AVR uCs. You really need to read the AVR datasheet's SPI and TWI sections carefully, do not skip a line. There are multiple control registers for data order, clock polarity, etc for each interface. It's all laid out in the datasheets, and is very readable. It would not be hard to link an AVR and PIC. You would just need to play with the SPI or TWI modes until you established communication.

  • 3
    \$\begingroup\$ ATtiny is the smaller brother of ATmega. They are very similar when it comes to programming them. I've 'ported' software from mega to tiny by just changing the part type in the Makefile. \$\endgroup\$
    – jippie
    Apr 23, 2013 at 19:21
  • \$\begingroup\$ @CamilStaps jippie makes a good point. I don't know if this is a similarity with PIC, but AVR processors for the most part share register names and bit orders. There are some exceptions, like a more capable processor may break a control register into two parts. The datasheets all have a register description section in each chapter that make the comparison easy. \$\endgroup\$
    – Matt Young
    Apr 23, 2013 at 19:29
  • \$\begingroup\$ PICs do as well, at least in one family (PIC16, PIC18, ..). Thanks for the tip (@jippie)! \$\endgroup\$
    – user17592
    Apr 23, 2013 at 19:33
  • \$\begingroup\$ This is a great explanation. My favorite AVR chips are ATmega328p and ATtiny24. Other common lines are the tinyx5 and tiny2313. These are all available in DIP, and all have the exact same SPI based programming interface: ISP. For a cheap, quick start, try this USB programmer from Sparkfun: sparkfun.com/products/9825 Also worth mentioning is a popular program bundle for Windows known as WinAVR: winavr.sourceforge.net You don't need any sort of a development board, just a power supply, bypass caps, and maybe a crystal. \$\endgroup\$ Apr 23, 2013 at 20:51

I work equally well on PIC and AVR (and others, too).

I like AVRs largely because of AVR-libc. It's a decent embedded library that is open source and reasonably well documented (UNLIKE Microchip's plib, but plib does have full source, which I genuinely appreciate). AVRs use regular old gcc and gdb which means no idiotic IDEs getting in my way. The same tools work on Windows, OSX and Linux, and I don't need a 600MB+ IDE with Java and Netbeans or Eclipse to trip over or pollute my source tree with their own garbage.

Programming AVRs is usually done via ISP or JTAG (there was a recent question about that), and from a programming standpoint, it's really not much different from any other micro.

From a personal perspective, I've grown to very much dislike Microchip's datasheets and part numbering. I cut my teeth on embedded design with Microchip and I loved them for a long, long time, but when I look for a micro these days I tend to start with Atmel, although they're not without their flaws too. (SAM-BA is garbage for their SAM parts, and I've had some trouble with their factory support too.)

As far as which to use... try both, it's like the difference between Coke and Pepsi. They are very, very similar and the choice usually comes down to price and the tools you prefer to use.

  • C will be the same with some small compiler differences. Assembly will be quite different since it's a different architecture. I advise going with C, and maybe pick up enough assembly to be able to inline some important routines.

  • For the IDE and programmer, Atmel have similar offerings to Microchip, just have a look at their website, download the free IDE and pick a programmer.

  • A similar chip to an 18F might be something like the ATMega328 (the one used in Arduinos) I believe they have DIP package versions.

  • Yes, I2C and SPI should work just the same. Linking an AVR and PIC should be no problem.

Disclaimer - I have not used an AVR for a long long time. I mainly use PICs and ARMs nowadays, but I have never had an issue connecting anything with SPI/I2C in the past, having frequently used SPI to connect between e.g. PIC/Atmel EEPROM/Cortex-M3/FPGA. SPI is a very basic protocol which pretty much any modern micro should be capable of in hardware.
I2C is a little more complex. I can't remember the story of the licensing/naming (e.g. 2-wire, I2C, SMBus) off the top of my head, but most peripherals are compatible at the basic level as far as I am aware. Have a read of the Wiki pages for more detail.

  • \$\begingroup\$ Atmel's TWI (Two Wire Interface) is compatible with I2C. I2C can be licensed from NXP (former Philips techology), but Atmel managed to work around the license fee. \$\endgroup\$
    – jippie
    Apr 23, 2013 at 19:17