Sie sind auf Seite 1von 9

PIC vs. AVR Ultimate fight!

OK, I know what you people want. You want ultimate fighting,
embedded E.E. style. You want to know WHICH IS BETTER, PIC OR
AVR?

Well, I know what side I'm placing my bets on (AVR of course) but for
99% of beginners, it doesn't matter too much which way you start.

Regardless, I'm tired of answering the same questions over & over, so
here we go!

Wait, what?

In the last few years, D.I.Y. electronics has taken a major leap forward
with the introduction of powerful yet low-cost, easy-to-program
microcontrollers. In this case I'll be talking about 8-bit micros, since
those are so popular. These chips cost a couple dollars, around $5, can
be programmed with a PC and a cheap programmer (usually on the
order of $30). They often have a few K of program ROM, around 1/2K of
RAM and some EEPROM. Theres some 'peripherals' such as built in
PWM, timers, A/D converters, etc.

Right now there are two major 'houses' of microcontrollers: the


Microchip PIC family and the Atmel AVR family. I have no idea what PIC
or AVR stand for (wikipedia sez: "Peripheral Interface Controller" and
"Advanced Virtual RISC" respectively) There's also the T.I. MSP430
which I've heard good things about from friends who have done
development on it, but not enough to put it in here, and the Silabs
micros which are awesome but not really for the amateur market.

I am not really an expert here, so please help me fill in this page with
more useful info, post it in forum! and make the topic something like
"PIC v. AVR". Please keep in mind that this page was originally written
in 2004.Thanks!

Packages

This is the first point, one which I think is pretty important. If you're doing
one off/prototype projects, you'll want a chip thats easy to work with.
That means DIP packaging.
Luckily, both AVR & PIC have lots of chips in DIP packages.

Winner? Its a tie!

Price

Price is a tough one to compare because sometimes one chip will have
more peripherals or RAM. So I'll compare three chip-sets, an 8-pin chip,
a ~20-pin chip and a 40-pin chip. They're also comparable in 'power,'
but you'll have to trust me on that. Prices are for single pieces from
Digikey

8-pin: PIC12F629 ($1.29) v. ATtiny13 ($1.40)


~20-pin: PIC16F628 ($3.35) v. ATtiny2313 ($2.26)
40-pin: PIC18F452 ($10.35) v ATmega32 ($8.17)

Winner? I think the numbers are pretty comparable. So I'm going to call
it a tie.
Languages

Parlez-vous turing completeness? If you cant use your language of


choice, its going to take a lot longer to get up to speed with your micro.
Here are some common languages & commentary.

Assembly: OK, yes of course you can write in assembly code. Both PIC
and AVR have free assemblers available by default from Microchip
(MPLab) and Atmel (AVRTools) for Windows. For AVR, there is also a
free unix command line assembler avra so you can run it under MacOS
X (which I've done successfully) or Linux. Likewise, PICs have gpasm,
which I've never used but I assume works good.
Overall, I've written some asm for both processors and I hate to break it
to PIC users but writing assembly for PIC is akin to stabbing myself in
the face. (Except its not even that efficient, cause you have to more the
knife into the working register first (movlw KNIFE), and then you can
stab yourself (movwf FACE).)
For people who've written assembly on other platforms, I'd compare it to
writing Intel assembly v. MIPS/RISC style. The Intel platform is
convoluted and very CISCy, whereas MIPS-esque processors have
fewer, simpler instructions.
At least AVRs dont have 'memory banks,' a true horror that makes
hand-written code, especially that with interrupts, nigh impossible.
Winner? On the matter of assemblers, its a tie but in the matter of
assembly itself, AVR is a clear winner.

C: C is a great language for microcontrollers: it was developed back


when mainframes had computational power/storage on the order of a
modern microcontroller (!). As a result, it's lightweight, fast and doesn't
come with useless stuff like garbage collection or 'objects' but does
come with arrays, functions, pointers, etc. For PICs, the 'standard'
compilers are from HiTech and CCS for windows. I've used CCS and
found it usable although it had some odd additions: it wouldn't let me
compile code that 'could' overflow the stack. However, it does have a lot
of nice macros built in. Steve M. writes:

I like targeting the ultra-low-end devices and horse-traded


with CCS for their $450 C compiler. It's not ANSI C by a
long shot and isn't even case sensitive (!), but if I hold my
mouth just right it usually compiles my code well enough.
But its greatest liability is that huge swaths of functionality
are "built-in" to the compiler (it has no linker), which means
that every week when Microchip comes out with a new
part your compiler becomes obsolete. All you need to do is
update the compiler, but that costs $250 a year for
"support" that I otherwise wouldn't use. So since my
license is 2 years old I just live without the cool new tiny
10F series and anything else new. HiTech C seems like a
better (ANSI) compiler but it's $1000 and still requires
$250/year "support" to keep up to date on the devices.
Very irritating.

There's also, apparently, a free compiler for PIC but I havent heard
much about it. Can someone send it in a note? There is a free compiler
for PIC available from Microchip, Dan Nguyen writes:

About the free PIC compiler, you just download it from the
Microchip
website and you can use it in the Microchip MPLAB IDE.
IT's actually
the student version and the only difference is that all
features are
only enabled for the first week. After that the only thing
that changes
is you can only have the compiler "optimize" your code to
level 2
instead of all the way- but most of the optimizations aren't
needed at
all and if you like your code to run exactly how you typed
it,
optimizations aren't for you.

Microchip says it doesn't update it as frequently as the


paid version
(but that's understandable).

There's also SDCC which I used to use a long time ago and was not a
fan of. However it is free and open source and compiles C code for
many (but not all) of the PIC devices.

On the AVR side pretty much everyone uses avr-gcc, a targeted version
of gcc for the AVR microcontroller. Theres a lot of good things about it.
One, it's completely free & works for Macs, Linux, Windows in a nice
distribution. Second it's 'real' C, which is great when you want things like
standard libs, includes, linking, unions, structs, and pointers (CCS at
least, struggled with these). It also means that porting code is really
easy because everyone uses it (all of PIC compilers aren't 100%
compatible). Third it generates good (fast, small and correct) code: the
optimizer is the same as in every other gcc.

Winner? I'm giving this one to AVRs: a free high quality compiler with full
optimizations, constant updates, supports all devices, and that is
completely cross platform? Hard to compete!
BASIC: I dont write code in BASIC so I dont have a lot of information on
this. I know that the Parallax BASICstamp boards are popular (see
below). I believe that they use the microEngineering Labs BASIC
compiler and I'm sure this compiler is pretty good. $99

On the AVR side, there's BASCOM. Also havent used it. $99

Winner? Lacking more information, I think it's a tie.

Software Integrated Development Environment (IDE)

I don't know too much about IDEs although I have played with both AVR
Studio as well as MPLAB and many people say that MPLAB is superior.
Granted, I haven't used the most recent MPLAB (I quit it around 5.x).
They're about the same, offering an easy assembler access.

Winner? Tie!

Caveat: Neither have reasonable C-compiler support, and both only run
on Windows. Mac? Linux? You don't get an IDE, roll one yourself.. So
they both lose in this regard

Note: Eclipse has been suggested to work with WinAVR but I couldnt
quite get it to work myself. YMMV.

Note2: CodeBlocks supports both PIC and AVR and FIRST uses it. If
those teenagers can do it, so can you!

Full Development Boards


So you want to start playing around, a good place to start is a full
Development board. The two compared here are from the
manufacturers:

PIC Kit 1: this is a relatively new little USB powered board


that comes with a bunch of LEDs, a prototyping area and
an RS232 converter.. An ideal starting point!
Pros: Simple, straight to the point, useful manual, and $40
Cons: However, no buttons, or anything else other than a
few LEDs and only supports a handful of chips.

STK500: An old stand-by. Tons of stuff including LEDs,


buttons, eeproms, variable oscillators, power supplies etc.
$80.
Pros: Full featured, the end-all-be-all of dev boards
Cons: Twice as expensive, serial port not USB so you
need a converter for Macs or some PCs

Winner? I'm leaning towards the PICKit1 here, since its cheaper.

"Beginner's" Dev boards

These are slightly different than the 'open ended' dev boards above.
These are more for people who are really starting for the first time with
Microcontrollers. There are two real options I see

BASIC Stamp: This ubiquitous little package from Parallax


pretty much dominates the market and is their
bread&butter. Programmable in 'BASIC', a PIC with a
BASIC interpreter + some eeprom (for storing instructions)
+ RS232 converter = Drop in solution for many
educational/robotics projects. $44
Arduino: An up and coming condender for "BASIC Stamp
killer", this is actually much larger (a small dev board
instead of 'chip' sized). Programming is done in
"proce55ing-like sketches" that are pretty much C with
some macros. Comes with USB instead of RS232. $32

Winner? At this point, BS is losing traction to Arduino. So AVR wins!

People support

PIC's and AVRs both have substantial support forums at PIClist and
AvrFreaks. From cursory observation, the fact that AVRfreaks has a full
featured website with forums (with threads!), projects, archives, RSS,
device comparisons etc. gives it ++ points of a mailing list that from their
own admission is constantly inundated with requests to unsubscribe. It
does have a projects selection and archives, despite the webpage looks
like it was made in 1997. (I dont particularly think that mailing lists are
an effective way of sharing electronis info for beginners)

On the other hand, both sites have badmouthed me & this page so I'm
takin this prize away! :-)

Winner? Neither!

Integrated Extras

One of the things you may want with your microcontroller is some
weirdo-extras like Ethernet, CAN, RF or USB support

I know microchip has an Ethernet PIC (although I have no experience


with it), and the USB PICs have been around long enough to be stable.
Atmel, on the other hand, hasn't seemed to go this route so if you want
hardware USB support built in, you should go with a PIC! (On the other
hand, there have been many examples of bitbang-USB successes for
the AVR)

Winner? PIC!

WEB REFERENCE ALL CREDITS:

http://www.ladyada.net/library/picvsavr.html

October 20, 2009 19:46

Das könnte Ihnen auch gefallen