PIC and AVR - Differences that may be missed?

Thread Starter

Robin Mitchell

Joined Oct 25, 2009
819
Hey all,

Just doing some research on PIC and AVR devices and it reminded me of what is arguably the biggest argument; PIC or AVR?

Now the general answer is "depending on what you are doing" but there is one thing that I believe is never covered; the AVR core.

On inspection of the assembly language for AVR it has over 150 instructions, has a 32 register bank, does not use banking, and has a higher MIPS per MHz than PIC. Is this missed out because most program in C and so don't see the micro-controller on that level?
 

Thread Starter

Robin Mitchell

Joined Oct 25, 2009
819
I forgot to mention that it has 16 bit pair registers for indirect register and a stack which reminds me of the Z80 but if it where a 1 clock cycle instruction!
 

kubeek

Joined Sep 20, 2005
5,795
Hi Robin, four times more Mips mer MHz seems nice, but notice that PICs run IIRC at roughly four times the clock speed, so there is no difference.
As for the C, i think the gcc compiler does a pretty good job of optimizing the code and using the cpu efficiently. I think there was only once when I had to resort to inline assembly to get bettter speed in a time critical routine.
 

alfonsoM

Joined Nov 8, 2017
41
Many engineers understand well and use well the digital part of the microcontroller but only small portion of them understand the hardware. For example; many don't understand why with lower supply voltage the frequency has to be lowered.
Only when you understand how the hardware works you can develop a reliable product.
 

philba

Joined Aug 17, 2017
959
I used to use PICs a lot but Arduino dragged me into the AVR camp. While I mostly program in C/C++, the AVR architecture is much cleaner than PIC and it comes through in a number of ways. But there are downsides - it's much easier to brick an AVR (or at least force you to use HV programming at which point I just toss the chip). I never bricked a PIC. Atmel Studio is a gawdawful mess. Also, Atmel has been pretty schizoid in their in-circuit debugging approach over the years leaving lots of relics out there.
 

QMESAR

Joined Dec 9, 2017
15
does not use banking, and has a higher MIPS per MHz than PIC. Is this missed out because most program in C and so don't see the micro-controller on that level?
Hi Robin

I just think you should mention it is possibly the case for 8 bit PICs because for 16 bit(PIC24/dsPIC30/33 ) and PIC32 it is total different story and they out perform many other position controllers controllers if you look at the DMIPS ratings issues by the official testing organization for mcu performance.

secondly I agree with this comments
Hi Robin, four times more Mips mer MHz seems nice, but notice that PICs run IIRC at roughly four times the clock speed, so there is no difference.
Kind Regards
 

Thread Starter

Robin Mitchell

Joined Oct 25, 2009
819
I just read in the AVR datasheet on how interrupts work. Wow, I love AVRs already!

PIC - single interrupt address and a bunch of comparisons to see which interrupt fired.
AVR- each interrupt type jumps to a specific address.

It seems that avr is focused on efficiency
 

philba

Joined Aug 17, 2017
959
By the way, check out the newest ATTinys - 161x. Lots of flash and ram for less than a buck. 3 16 bit PWMs, SPI, I2C, serial, 1.8V. schweet. All SMDs, though. Not a problem for me but it may slow some people down. I'm thinking of doing the hardware stuff to allow use of the Arduino IDE for them.
 

QMESAR

Joined Dec 9, 2017
15
:) You guys are aware that ATMEL-AVR is microchip company and all the multiple vector Interrupts is also in the PIC 16 Bits and 32 Bit MCU it is not unique to AVR -
AVR's are great micro's agreed, However I still prefer a PIC16F1xxx family as the independent peripherals is much more valuable that the single vectored interrupts in small micro's just my 2 cents
 

philba

Joined Aug 17, 2017
959
You know very well that the PIC has a stack...but anyways...check out this article....especially around the heading
So why are you using a PIC anyway?

Maybe Microchip felt the same way and figured, better buy Atmel and their AVR chips :)
You are absolutely correct the PIC (PIC 16, anyway) has a stack. Just don't use it more than a couple of levels deep because that's as far as it goes. From a software perspective, the PIC stack is kind of a joke.

I have to say I had a sinking feeling when they announce the acquisitiion. Though there are still new chips coming out of the Atmel side.
 

Thread Starter

Robin Mitchell

Joined Oct 25, 2009
819
I would not consider the PIC stack a true stack. Its only purpose is for use when calling routines. Using the stack is potentially dangerous.
 

nsaspook

Joined Aug 27, 2009
13,315
There will be fewer differences in the future.;)
I just read in the AVR datasheet on how interrupts work. Wow, I love AVRs already!

PIC - single interrupt address and a bunch of comparisons to see which interrupt fired.
AVR- each interrupt type jumps to a specific address.

It seems that avr is focused on efficiency
The K42 has vectored interrupts (and other advanced features). https://www.microchip.com/promo/pic18f-k42
 
Last edited:
I have never been so excited to play with a chip in my life!
Or at least since a month ago. ;)

I am just as bad, if not worse....and have a third new board that I am excited about coming tomorrow.

On the AVR, I got one of these a while ago - very cheap. I confess that I am still getting started and have only got to installing and running an LED hello world. So far though, they seem to be a cheap plug-and-play option for getting my feet wet.
 

philba

Joined Aug 17, 2017
959
On the AVR, I got one of these a while ago - very cheap. I confess that I am still getting started and have only got to installing and running an LED hello world. So far though, they seem to be a cheap plug-and-play option for getting my feet wet.
That cracks me up. The interface chip is huge compared the to 104.
 
That cracks me up. The interface chip is huge compared the to 104.
Yep! When I got it, I also got some ATTINY45V-10PU DIPs - just took this pic which offers another comparison:

IMG_8620.JPG

But, of course, as you know it is a breakout board to sell the chip by making it easy for it to be "Xplained". BTW: I also just looked up the invoice, paid $6 for the board and $1.53 for the chip, with free shipping. Back in March, so since March, I have flashed an LED :) On the other hand, I paid that much for a couple of cups of coffee and they are gone - still have the board and chip.
 
Top