AVR vs PIC Battle Royal: Recomendations

Hello all!

I just had an oopsie on my pic dev board while writing a motion control routine with a unipoler stepper that went out of control and I shorted my breadboard. 16F877A up in smoke and programmer gives wierd errors so I figured now that I need a new setup lets see which rout to go.

For the obvious start lets compare hardware capabilities. On the pic side of things I use 16f870, 16f877a, 18f452 and 18f4550 the 4550 was chosen to be a ICSP from http://usbpicprog.org/ and the chip I prefer to use is the 877A @ 20MHz

Available on the 16f877a:

35 Instructions

Most instructions are 2 cycle

8k flash

368 data

256 EEPROM

15 Interrupts

Ports A/B/C/D - E is only 3 pins whoo

2 - 8bit timers

1 - 16bit timer

I2C/SPI/USART

8 - 10bit ADC

2 - Analog Comparators

2 - PWM Channels

40pin Dip

ATMEGA16:

131 Instructions

Most single cycle

16k flash

512 EEPROM

1K ram

JTAG Complaint

21 Interrupts

Ports A/B/C/D

2 - 8bit timers

1 - 16bit timers

4 - PWM Channels

I2C/SPI/USART

8 - 10bit ADC

1? - Analog Comparators

Onboard RTC

40pin DIP

OK so theirs quit similar in hardware, the things that stand out to me are the AVR has ALOT of features that are independently setup, onboard RTC, 4 PWM channels, larger flash/EEPROM/ram and the #1 that most instructions are single cycle so a 16MHz osc will probably seem as fast as the 20MHz pic. In the pic’s defence its strong point is its downside, their are so many avalible you can find one with just what you need but next project you need something else…

2nd issue, Programmers and Programming Suites:

I have no idea what AVR has to offer, I use MikroC (http://www.mikroe.com/en/compilers/mikroc/pic/), I have used Hi-Tech C and hated it, and microchips suit thats ok but bad interface. Programmers are easy to find parallel/serial/usb I use the cheep usbpicprog setup. What are my options for cheep programmers and good programming suites comparable to MikroC in quality but preferably without a closed source library?

Well thats all I can think of at the moment, I ask anyone with both pic & avr experience using C can give me their reasons for choosing one or the other, thanks!

On a side note here is what I was running:

EasyPIC4 (no touch screen) http://www.mikroe.com/en/tools/easypic5/

Was running a 36V 2A 75os/in unipoler stepper, was powered via PWM from the pic and a darlington phase setup the 36V rail shorted to one of the pics ports and suddenly all it would do is randomly 1/0/Z all pins.

What Im thinking of replacing it with:

http://www.mikroe.com/en/tools/pic-ready/ for PIC

http://www.mikroe.com/en/tools/avr-ready/ for AVR

Or I will make a simple carrier board for the uC & osc to plug into my breadboard.

It really comes down to which one has the features you need for a particular job. As you say, it’s often easier to find a PIC with a good match to the requirements. On the other hand, the AVR has a nicer architecture, is easier to program and a lot faster for a given clock frequency (the PIC instruction cycle is 1/4 the clock frequency). I much prefer MPLAB to AVR Studio, and the Microchip assembler is better than that for the AVR. AVR has free gcc. The Microchip ICD 2 and PICkit2 are much better than the equivalent AVR tools, like the Dragon. There really isn’t much in it, so I use both.

Leon

leon_heller:
On the other hand…

Thanks for the response, can you expand on what you mean by a nicer architecture & easier to program?

With 131 assy instructions I can see how things are easier to comprehend at the assy level than pics 24 but I dont ever deal with assy mostly because L & W registers and if zeros hurt my brain…

Easier to program? I only see the pic’s drawback there as the low voltage, 5v or 12v’s needed in different cases. I assume the entire avr line is quit standardized. Im still doing research but most everything I know from pics is through experience.

One thing I dislike is the fact I ALWAYS need my pic’s manual out to set up the interrupts, ADCON, prescalers, etc as the names of the settings are the same but the bit set order is always different. So when my 16f877a died I would need to re-write alot of things if I where to use the 18f452 instead.

I hate MPLAB sooo much, its got terrible window management inside itself which alone is enough of a pain in the neck to not use it. It is nice that everything is open and available to see how they implemented it but that ide…

Are their many diy/cheep(~$20) programmers available for the AVR Studio? most diy/cheep pic programmers ar not compatible with MPLAB which is another reason I never use it.

Thanks.

I changed from PICs to AVRs long ago because

PICs (excluding the new PIC24) don’t have a conventional stack. Many problems and inefficiencies arise from that.

PICs (excluding, as above) cannot directly address more than 256 bytes of RAM without absurd bank switching. Though hidden from a high level language programmer, the underlying code has to be there and it is very wasteful of code space and time.

PICs don’t have a free well supported C compiler and IDE like GCC (WinAVR), and that’s integrated by Atmel into their IDE. And there are two or more inexpensive commercial C compilers (codevision, Imagecraft) that are more/better, and certainly no where near the cost for PICs.

The Atmel branded ISPs are inexpensive. One from NKC electronics is compatible with AVR Studio and is a JTAG. Lots of AVR folks use serial port downloaders and there are many free ones on AVRfreaks.net.

That’s my viewpoint.

Thanks stevech,

That some good things pointed out, I had issues at first dealing with the strange pic constraints such as variables don’t go out of scope, the call table can only be 6 deep, strange stack workings. I got useto it but its kind of a bad thing to get useto…

Ive been playing with AVR Studio 4 all night and I LOVE it, very clean and just as fast and well laid out as MikroC that i am use to, the huge deal is the software simulator on the right with port views and all the internals, interrupts, timer paddins, everything useful to watch when trying to figure errors out. Ive tried ICD with the pic’s trying to figure out why the pic was bastardizing the captured string and it never worked as the usart rx flag never came on therefore nothing was ever captured, took two days before I threw it around the room…

I just found a AVR Paralell port programmer that only needed 2 resistors, that’s insane…

There are plenty of C compilers integrated into MPLAB, and there are free versions of several of them, like the Student editions of C30, C18 and C32.

By “easier to program” I meant software development - the AVRs don’t have banks that have to be switched, and have a nice linear memory map. They also have a proper stack.

Leon

If you are burned out on PICs, I suggest you take a close look at going to ARM7 microprocessors rather than AVRs.

The ARM microprocessors are produced by a dozen or so manufacturers, most notably NXP, previously Phillips Semi. The ARM7s, as a small board/module, or a chip, price competitive with the top of the PIC and AVR lines, though the ARM7 is a full blown 16 or 32 bit processor. And they don’t have the dual address space that PIC/AVR has which is good for speed but bad for software development tools.

There are many, many ARM7 modules for sale: Olimex, Coridium, and others cater to schools and hobbyists. Some sold here on SFE. Also web forums such as lpc2000 on yahoo groups.

I’ve switched my emphasis from AVR to ARM7. The ARM9 (big brother of ARM7) is what is in many/most PDAs and other handheld devices. That’s why they are inexpensive despite their sophistication.

iceblu3710:
Thanks stevech,

That some good things pointed out, I had issues at first dealing with the strange pic constraints such as variables don’t go out of scope, the call table can only be 6 deep, strange stack workings. I got useto it but its kind of a bad thing to get useto…

Ive been playing with AVR Studio 4 all night and I LOVE it, very clean and just as fast and well laid out as MikroC that i am use to, the huge deal is the software simulator on the right with port views and all the internals, interrupts, timer paddins, everything useful to watch when trying to figure errors out. Ive tried ICD with the pic’s trying to figure out why the pic was bastardizing the captured string and it never worked as the usart rx flag never came on therefore nothing was ever captured, took two days before I threw it around the room…

I just found a AVR Paralell port programmer that only needed 2 resistors, that’s insane…

Here's a neat AVR ISP and JTAG: I have one; works with Studio.

http://www.nkcelectronics.com/avr-jtag- … r-kit.html

But I also use serial port bootloaders on AVRs. See

http://www.avrfreaks.net/index.php?modu … tem_id=625


More on Microchip versus AVR at the ethics in management level:

http://www.avrfreaks.net/index.php?name … ic&t=72544

One area where AVRs are really deficient is PWM. PICs like the 18F1220 have much better PWM hardware for motor control.

Leon

In the “why not ARM” department

http://www.futurlec.com/ARM2103_Controller.shtml

and

http://www.olimex.com/dev/lpc-p1.html (SFE resells Olimex)

and coridium’s boards (sold here)

The NXP 2103 and 2106 and others have a serial port bootloader pre-programmed at the factory.

For compilers, there’s

IAR’s commercial compiler, free version supports up to 32KB of code.

WinARM - GCC version for ARMs.

YAGARTO - Eclipse IDE and GCC, nice IDE. Free

etc

leon_heller:
One area where AVRs are really deficient is PWM…

Good to know, on my stepping psu I was very pleased at how clean the PWM from my pic was as 35kHz 0/100% duty. And very easy to control since duty is just an 8bit register

stevech:
In the “why not ARM” department…

Big thanks for the futurelec.com link for $25 im gonna get one just for the odd project I need some extra horsepower.

I do really like ARM’s and would like to work on them the majority of the time but unfortunately they are not breadboard friendly at all. If I made a qtfp44 - 40pin 600dip then it would be much easier to prototype with as right now im using separate dev boards and on the 2x10 headers I pull the port pins out to a 1x8 + 1x2 to power the breadboard and things get loose and thats how I blew my pic dev board my port header touched my 12v supply line.

When I get my pcb mill running I will use more arm’s as I have a few complex projects.

I think I am going to end up getting a replacement sample of my 16f877a and make a small breakout for pic/avr/arm.

http://www.mikroe.com/en/tools/pic-ready/

http://www.mikroe.com/en/tools/avr-ready/

Since these guys are dip’s im going to make a wide carrier board that puts the OSC/reset/ICSP on a riser board with a 40pin socket for the uC and organize the port pins to the sides (-above pins) since that’s essentially all those dev boards do.

for breadboarding, I buy development boards where the CPU, RS232/USB, DC regulator, etc. are all mounted, often as surface mount. I add my goodies in the provided prototyping area on these boards. The solderless breadboards are fine for a super simple circuit, but much more, it gets too time-consuming.

stevech:
for breadboarding, I buy development boards where the CPU, RS232/USB, DC regulator, etc. are all mounted, often as surface mount. I add my goodies in the provided prototyping area on these boards. The solderless breadboards are fine for a super simple circuit, but much more, it gets too time-consuming.

That begs a question: When you are done with your prototype, do you take the time to unsolder everything or do you just end up buying a new dev board? The reason I ask is that I’ve found taking a soldered design apart afterward is fairly time consuming and usually leaves some damage to the circuit board itself (heat can cause lifted pads, etc). If possible, I would much rather use a solderless breadboard or wire wrap tools.

signal7:

stevech:
for breadboarding, I buy development boards where the CPU, RS232/USB, DC regulator, etc. are all mounted, often as surface mount. I add my goodies in the provided prototyping area on these boards. The solderless breadboards are fine for a super simple circuit, but much more, it gets too time-consuming.

That begs a question: When you are done with your prototype, do you take the time to unsolder everything or do you just end up buying a new dev board? The reason I ask is that I’ve found taking a soldered design apart afterward is fairly time consuming and usually leaves some damage to the circuit board itself (heat can cause lifted pads, etc). If possible, I would much rather use a solderless breadboard or wire wrap tools.

If I do a really simple experiment, yes, I reuse the board.

A complicated one often goes into useful long term service.

I also often buy I/O daughter cards that have 0.1 in. connectors and I mate it to a header I put on the prototype board. Example: ConnectOne’s WiFi board.

I prefer to not have to wire up the basic CPU, crystal, regulator, RS232/USB.

signal7:
I would much rather use a solderless breadboard…

Indeed usually after a use or two soldered boards pads start to lift. I use a breadboard with basic components to prove my concepts and code then goto smt with calculated values.

Where breadboarding sucks is when you need those things like rs232/icsp/etc and you gotta wire each one up. I have an rs232 breakout with the max chip so I only need to give it power & rx/tx but would prefer a chip carrier that orginizes the port pins nicely and has the osc and icsp already. that would make prototyping much faster.

For ARM7s, Coridium’s Wireless ARMmite is easy to use, as are many of the Olimex boards for various micros