Which is better.. PIC or AVR ?

April 11, 2009 at 22:42 (microcontroller)

Ways in which PICs are better than AVRs

Instruction set/architecture (for Assembler users)
PIC good : Small instruction set means you can literally learn it in a day. Skip instructions can often simplify flow-control.

AVR bad : highly nonorthogonal instruction set – many operations can only be done on certain registers. Relative branch range can force code to be arranged in a non-logical order. No immediate XOR instruction. Illogical mixture of skip and branch flow-control instructions (Now if only they’d made STATUS one of the registers you could do skips on….!).

Clocks etc.

PICs (12Fxxx etc.) have more accurate calibrated RC oscillators.

Watchdog wakeup from sleep continues after SLEEP instruction – on AVR it causes a reset, which can complicate things.


Interrupt latency is constant – if you set up a regular timer interrupt on a PIC, it will occur at exactly the same interval every time. On the AVR you will get at least one cycle jitter.

I/O and bit-twiddly things
I/Os are the same as other file registers, so operations other than bit set/clear operations take less work – bits can be toggled using XORWF, multiple bits can be set or cleared simultaneously using ANDWF or IORWF, and you can do neat tricks like using an output port as a shift-register for really fast pattern generation. The latter is not often useful, but does allow neat stuff like video generation.

Ways in which AVRs are better than PICs.

Instruction set/architecture

AVR good : Add with carry, and compare with carry simplify multiple precision arithmetic. Good range of conditional branches.

PIC bad : Unconventional mnemonic names.. Only one pointer for indirection. Inefficient lookup tables. No add/subtract with carry, small stack. Paged architecture becomes a real pain on larger projetcs, although the PIC18 architecture addresses (pun intended!) many of the issues.

Clocks etc.
Wider range of RC oscillator speeds. PLL high-frequency IO clock on some parts for high-speed captre etc.

More instructions per oscillator clock, but as most instructions take 2 cycles, and more instructions are often necessary for IO intensive tasks, this advantage is 2:1 at best. Most embedded apps are not especially throughput-dependent. Also, crystals and resonators get bigger and harder to get much below about 3MHz, so the speed advantage over a 4MHz PIC can often not be a major issue.

Watchdog can be turned off by software.

TX and RX can be enabled seperately – useful for multi-processor comms on a common bus. High baudrates are possible from low clock frequencies.

Vectored interrupts are more efficient where there are multiple interrupt sources, and registers can be reserved for interrupt-only use to speed up context save for low latency.

Seperate PORT and PIN registers avoid read-modify-write issues with capacitively loaded pins. (Although has any AVR user never spent time wondering why their input port isn’t working because they used PORTx instead of PINx…? ).

And the winner is…..

If you’ve read the above, you’ll have realised that the answer is Neither of course, it all depends on what your requirements are, however that in almost all fields of enginering, there is simply no such thing as “Best”. The correct phrase is “Most appropriate for your application”

………………….if you found this tutorial helpful or have any suggestions … do leave a comment.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: