# PIC vs AVRs

#### lz5480

Joined May 8, 2006
4
hi...

I'm newbie in microcontroller and I need your help.
What is the different between PIC and AVR.
Which of both have better support (forums,tools..etc), easy to use and to programmed.

Thank you.

#### Papabravo

Joined Feb 24, 2006
14,378
I'm not sure that it makes sense to do a side by side comparison. Part of this reticence comes from the fact that each family has a large number of variants. In many cases the choice of a part often comes down to the number of pins, the package, the cost of the chip, the peripherals, the cost of the halo, the operating voltage, the current consumption, and so forth. The internal architecture of the ALU and the instructions is pretty low on my list of priorities.

They both have assemblers, they both have compilers for high level languages, they both have emulators, development tools, and programmers. Once you use one, you develop a feel for what it can and cannot do. If you have the luxury I would try to learn multiple parts. If not, let's see what the other folks think on this isssue.

#### hgmjr

Joined Jan 28, 2005
9,029
Originally posted by lz5480@May 8 2006, 07:54 PM
hi...

I'm newbie in microcontroller and I need your help.
What is the different between PIC and AVR.
Which of both have better support (forums,tools..etc), easy to use and to programmed.

Thank you.
[post=16931]Quoted post[/post]​
Greetings lz5480,

The following reply is strictly IMHO.

Papabravo is correct, your choice of PIC or AVR is largely a matter of what you plan to do with the microcontroller. Both device families have similar features as well as unique features so the process of choosing one can be daunting.

I am blatantly biased as I recently purchased an ATSTK500 Starter kit from Digikey ($80) for use in program development for Atmel's AVR series of microcontrollers. I chose the AVR over the PIC mainly for economic reasons. Atmel has elected to make all of their AVR series development tools available FREE from their website. You can download their very flexible assembly language development tool called AVRStudio 4.12 from www.atmel.com. The software development tools I looked at for the PIC series cost several hundred dollars. I am not very familiar with PIC but I believe that the PIC series devices are mainly one-time-programmable. That means that you will probably have to discard the PIC if your code has a bug in it. That means no do-overs. The AVR series devices are FLASH, EEPROM and SRAM based devices so they can be reprogrammed thousands of times. They are also In-System Programmable which means you can layout your PC board and then refine your program afterwards. I have had my ATSTK500 for a month or so and it has proven to be a real blast. I'm certain that the PIC series is a terrific family of microcontrollers with many great features. It is just that the AVR series made more sense for my budget and application. hgmjr Thread Starter #### lz5480 Joined May 8, 2006 4 Originally posted by hgmjr@May 9 2006, 02:22 AM Greetings lz5480, The following reply is strictly IMHO. Papabravo is correct, your choice of PIC or AVR is largely a matter of what you plan to do with the microcontroller. Both device families have similar features as well as unique features so the process of choosing one can be daunting. I am blantantly biased as I recently purchased an ATSTK500 Starter kit from Digikey ($80) for use in program development for Atmel's AVR series of microcontrollers.

I chose the AVR over the PIC mainly for economic reasons. Atmel has elected to make all of their AVR series development tools available FREE from their website. You can download their very flexible assembly language development tool called AVRStudio 4.12 from www.atmel.com. The software development tools I looked at for the PIC series cost several hundred dollars.

I am not very familiar with PIC but I believe that the PIC series devices are mainly one-time-programmable. That means that you will probably have to discard the PIC if your code has a bug in it. That means no do-overs.

The AVR series devices are FLASH, EEPROM and SRAM based devices so they can be reprogrammed thousands of times. They are also In-System Programmable which means you can layout your PC board and then refine your program afterwards.

I have had my ATSTK500 for a month or so and it has proven to be a real blast.

I'm certain that the PIC series is terrific family of microcontrollers with many great features. It is just that the AVR series made more sense for my budget and application.

hgmjr
[post=16943]Quoted post[/post]​

hi... hgmjr

Thank you for your help.I look at the internet there are many compiler for both.
How about Basic compiler? Does it raise the result as good as if it use assembly directly?

lz5480

Joined Jan 10, 2006
614
Originally posted by lz5480@May 10 2006, 12:24 AM
hi... hgmjr

Thank you for your help.I look at the internet there are many compiler for both.
How about Basic compiler? Does it raise the result as good as if it use assembly directly?

lz5480
[post=16961]Quoted post[/post]​
If you want to program in BASIC, then I would suggest the PICaxe series from Revolution Education. They are basicaly a PIC with a basic interpreter loaded onboard (similar in operation to the "STAMP" series but cheaper). They have internal osc, and require only a very minumum interface (5 volt supply and a lead to connect to the RS232 port on your PC) and can be reprogrammed. I use them for a lot of small one off projects, and the tiny PICaxe8M is my favourite, with 5 combination I/O's (which can also be configured as 10bit ADC, IR input or PWM out or even Servo control) and Serial I/O all in an 8 pin package, with enough progam memory for 80 lines of code..(as I recall).
The chips are as Cheap a Chips..( about $4 or$5 each landed here in NZ) and the software is Free from the Revolution Education website, along with lots of sample Apps, instructions, command list and ideas. The PICaxe 18 series is also popular for the more intense projects.
Probably not the way to go if you want high speed or complex functions...

#### lz5480

Joined May 8, 2006
4
Originally posted by Gadget@May 9 2006, 10:33 PM
If you want to program in BASIC, then I would suggest the PICaxe series from Revolution Education. They are basicaly a PIC with a basic interpreter loaded onboard (similar in operation to the "STAMP" series but cheaper). They have internal osc, and require only a very minumum interface (5 volt supply and a lead to connect to the RS232 port on your PC) and can be reprogrammed. I use them for a lot of small one off projects, and the tiny PICaxe8M is my favourite, with 5 combination I/O's (which can also be configured as 10bit ADC, IR input or PWM out or even Servo control) and Serial I/O all in an 8 pin package, with enough progam memory for 512 lines of code..(as I recall).
The chips are as Cheap a Chips..( about $4 or$5 each landed here in NZ) and the software is Free from the Revolution Education website, along with lots of sample Apps, instructions, command list and ideas. The PICaxe 18 series is also popular for the more intense projects.
Probably not the way to go if you want high speed or complex functions...
[post=16962]Quoted post[/post]​

Thank you for your suggestion, but... what is the different with Basic Stam?

lz5480

#### lz5480

Joined May 8, 2006
4
Originally posted by Gadget@May 9 2006, 10:33 PM
If you want to program in BASIC, then I would suggest the PICaxe series from Revolution Education. They are basicaly a PIC with a basic interpreter loaded onboard (similar in operation to the "STAMP" series but cheaper). They have internal osc, and require only a very minumum interface (5 volt supply and a lead to connect to the RS232 port on your PC) and can be reprogrammed. I use them for a lot of small one off projects, and the tiny PICaxe8M is my favourite, with 5 combination I/O's (which can also be configured as 10bit ADC, IR input or PWM out or even Servo control) and Serial I/O all in an 8 pin package, with enough progam memory for 512 lines of code..(as I recall).
The chips are as Cheap a Chips..( about $4 or$5 each landed here in NZ) and the software is Free from the Revolution Education website, along with lots of sample Apps, instructions, command list and ideas. The PICaxe 18 series is also popular for the more intense projects.
Probably not the way to go if you want high speed or complex functions...
[post=16962]Quoted post[/post]​

Thank you for your suggestion, but... what is the different with Basic Stam?

lz5480

#### hgmjr

Joined Jan 28, 2005
9,029
Originally posted by lz5480@May 10 2006, 12:24 AM
hi... hgmjr

Thank you for your help.I look at the internet there are many compiler for both.
How about Basic compiler? Does it raise the result as good as if it use assembly directly?

lz5480
[post=16961]Quoted post[/post]​
I am not exactly clear on your question but I think you are asking "Is it better to use asssmbly language than Basic compiler?".

When it comes to the different programming languages, there are several trade-offs that exist. You can use a high-level language like Basic or "C" to make it easier to write the program. The trade-off is that the high-level language puts you at the mercy of the Compiler designer's implementation of the high level commands using assembly language. Portability of code across many different devices is one of the advantages of high-level languages. Another advantage to high-level languages is that other programmers can easily take your high-level language coded program and modify it to suit their needs.

Using assembly language is a bit (no pun intended) more complicated since you must take care of all of the low-level routines yourself. For this extra effort you get the ability to write very compact code from the stand-point of memory usage. This advantage can sometimes be critical in the microcontroller world since the available memory is often limited.

It has been my opinion that a programmer with a good grasp of assembly language can make better use of a high-level language since they can alway resort occassionally to writing their own assembly languge subroutines to take greater advantage of the hardware. Of course by doing so, they have to be willing to abandon portability.

In the end, the choice of programming language to use comes down to personal preference and your specific application.

hgmjr

Joined Jan 10, 2006
614
Originally posted by lz5480@May 11 2006, 01:14 AM

Thank you for your suggestion, but... what is the different with Basic Stam?

lz5480
[post=16999]Quoted post[/post]​
To program.... very little, but it is a single chip (a PIC with a bootstrapping routine loaded to allow direct connection to RS232 without an interface) and is very cheap...probably less than 1/10 the cost of a Basic Stamp.
If it interests you I suggest you google PICAXE or Revolution Education.

#### lz5480

Joined May 8, 2006
4
Originally posted by Gadget@May 13 2006, 07:29 PM
To program.... very little, but it is a single chip (a PIC with a bootstrapping routine loaded to allow direct connection to RS232 without an interface) and is very cheap...probably less than 1/10 the cost of a Basic Stamp.
If it interests you I suggest you google PICAXE or Revolution Education.
[post=17066]Quoted post[/post]​

Thank you very much for your help.

lz5480

#### Turbokeu

Joined Oct 20, 2004
3
Originally posted by hgmjr@May 9 2006, 12:22 PM
I chose the AVR over the PIC mainly for economic reasons. Atmel has elected to make all of their AVR series development tools available FREE from their website. You can download their very flexible assembly language development tool called AVRStudio 4.12 from www.atmel.com. The software development tools I looked at for the PIC series cost several hundred dollars.

I am not very familiar with PIC but I believe that the PIC series devices are mainly one-time-programmable. That means that you will probably have to discard the PIC if your code has a bug in it. That means no do-overs.

The AVR series devices are FLASH, EEPROM and SRAM based devices so they can be reprogrammed thousands of times. They are also In-System Programmable which means you can layout your PC board and then refine your program afterwards.

[post=16943]Quoted post[/post]​
Hello to all, first post here.

All Microchip PIC microcontrollers with an 'F' in their denomination (ex. 16F628, 18F458) are flash-based controllers which can, like the AVR's, be reprogrammed thousands of times. All PIC's also contain SRAM and EEPROM memory.
Only PIC's with a 'C' (ex. 16C54) are OTP (One Time Programmable).

Microchip has a free Integrated Development Environment (IDE) which is MPLAB, basically meant for ASM (assembler) programming.
Several third party programming languages environments (C, Basic, ...) can be easily integrated into MPLAB.
Most of these (commercial) third party programming languages have a free download version with a 2 kilobyte generated code limitation.

I have no experience with those packages as I only program in ASM.

CD

Edit: I just saw it's my second post on this forum...

Joined Aug 11, 2005
105
I've not actually used either of them yet, but I've been doing a lot of reading lately.

Turbokeu said what I was thinking about flash-based devices and software development tools. In addition, many of the PIC devices do support in-circuit programming.

For starter kits, the PICkit2 (DV164120) is around $60, and I'm probably going to get that one. Edited to add: I've downloaded both AVRStudio and MPLAB, and as a total newbie, I found MPLAB to be much less intimidating. Though, that says nothing about which one is nicer to use for more experienced users. That's a possibility for you though if you can't decide based on second-hand information. Both pieces of software include a chip simulator that you can run your programs on; so there's nothing stopping you from learning to program both PIC and AVR, and making an informed decision on which one you prefer before putting any money on it. #### Dave Joined Nov 17, 2003 6,970 Originally posted by Turbokeu@May 28 2006, 07:33 AM Hello to all, first post here. All Microchip PIC microcontrollers with an 'F' in their denomination (ex. 16F628, 18F458) are flash-based controllers which can, like the AVR's, be reprogrammed thousands of times. All PIC's also contain SRAM and EEPROM memory. Only PIC's with a 'C' (ex. 16C54) are OTP (One Time Programmable). Microchip has a free Integrated Development Environment (IDE) which is MPLAB, basically meant for ASM (assembler) programming. Several third party programming languages environments (C, Basic, ...) can be easily integrated into MPLAB. Most of these (commercial) third party programming languages have a free download version with a 2 kilobyte generated code limitation. I have no experience with those packages as I only program in ASM. CD Edit: I just saw it's my second post on this forum... [post=17365]Quoted post[/post]​ Hi and welcome to the forums, I was always under the impression that the C18 compiler for programming PICs in C was a paid for software with no limited free version, having looked around Microchip's website I cannot find anything to the contrary. There is a free student version which functions under certain time-limiting restrictions which alters certain optimisations making your code less efficient. Dave #### Turbokeu Joined Oct 20, 2004 3 Originally posted by Dave@May 28 2006, 05:03 PM Hi and welcome to the forums, I was always under the impression that the C18 compiler for programming PICs in C was a paid for software with no limited free version, having looked around Microchip's website I cannot find anything to the contrary. There is a free student version which functions under certain time-limiting restrictions which alters certain optimisations making your code less efficient. Dave [post=17377]Quoted post[/post]​ Thanks! I wasn't really talking about the Microchip C18 compiler (I even forgot about it!), which is BTW only meant for the PIC 18F-series, but more about about the CCS and Hitech C-compilers for the 16F-series... PS: Again, I have no experience with these packages as I only program in ASM (even on 18F PICs). CD #### Dave Joined Nov 17, 2003 6,970 Originally posted by Turbokeu@May 28 2006, 07:17 PM Thanks! I wasn't really talking about the Microchip C18 compiler (I even forgot about it!), which is BTW only meant for the PIC 18F-series, but more about about the CCS and Hitech C-compilers for the 16F-series... PS: Again, I have no experience with these packages as I only program in ASM (even on 18F PICs). CD [post=17384]Quoted post[/post]​ Having only used the PIC18F series of microcintrollers, this will explain why I am not familiar with these other C-compilers for PIC microcontrollers. Thanks. Dave #### Gorgon Joined Aug 14, 2005 113 Hi, For what it is worth, I prefer the AVR for the PIC. I normally program in assembly and PIC assembly and paging is a pain in the neck. I've only used the PIC16 versions, and understand that PIC18 is more like a normal micro. If everything was equal, I would prefer Atmel. Well, what I really would prefer is the Freescale variants of micro's, but I know this has a cost for the hobby user. Whatever micro you select, learn the hardware, study the datasheet and understand how and why shit happens. It will! The main problem for newbies in my experience, is the fact that running a program in a micro takes time, sometime lots of time and you need to take this into account when making a program. This is very important when you make programs with human interaction. We are slow, most of the time! Good luck on the road to runtime errors TOK #### bitman Joined Jan 12, 2006 3 I too are a beginner with micro's I first dabbled with some pre made pic micro boards but found that high level programming software and hardware is quite expensive. I have just started with an avr board using the ATMega8535 from a company called futurlec.( www.futurlec.com) For less than$20 USD if my memory serves me correctly you get a board with 4, 8 bit ports, analog capabilities, i2c, spi, eeprom (onboard the micro).

I have used the mikrobasic for avr from mikroelectronika www.mikroe.com
had the board working within 1/2 an hour of recieving the micro.

I very much reccomend the AVR, particularly the programming seems easier and cheaper.

I could be wrong... but that my 10 cents worth

Good Luck

#### DKNguyen

Joined Dec 31, 1969
0
Dave said:
Hi and welcome to the forums,

I was always under the impression that the C18 compiler for programming PICs in C was a paid for software with no limited free version, having looked around Microchip's website I cannot find anything to the contrary. There is a free student version which functions under certain time-limiting restrictions which alters certain optimisations making your code less efficient.

Dave
Actually, the free version IS the student version and can be used for free indefinately with a single restriction that kicks in after a week, but let me clarify something about this restriction. It doesn't make your code less efficient (I don't know why Microchip words it like this unless they believe people want to use their PICS so much they would pay for the compiler rather than use the student version). The compiler doesn't go out of its way to make your code less efficient. Rather, what it does is not optimize your code as much as the paid version (level 2 instead of level 5 optimization if I remember right). So it's really not a problem, especially if you want you code to run exactly as you have written it. So really the worst thing that can happen is that you get what you coded.

That is something very important to know if you are deciding between PIC and AVR. The free Microchip PIC compiler DOES NOT ACTIVELY MAKE YOUR CODE LESS EFFICIENT- what it does is not go through your code and optimize it as much as the paid version. It's practically the same product. The worst that can happen is that your code is as bad (or as good) as you wrote it.

#### Dave

Joined Nov 17, 2003
6,970
DKNguyen said:
Actually, the free version IS the student version and can be used for free indefinately with a single restriction that kicks in after a week, but let me clarify something about this restriction. It doesn't make your code less efficient (I don't know why Microchip words it like this unless they believe people want to use their PICS so much they would pay for the compiler rather than use the student version). The compiler doesn't go out of its way to make your code less efficient. Rather, what it does is not optimize your code as much as the paid version (level 2 instead of level 5 optimization if I remember right). So it's really not a problem, especially if you want you code to run exactly as you have written it. So really the worst thing that can happen is that you get what you coded.

That is something very important to know if you are deciding between PIC and AVR. The free Microchip PIC compiler DOES NOT ACTIVELY MAKE YOUR CODE LESS EFFICIENT- what it does is not go through your code and optimize it as much as the paid version. It's practically the same product. The worst that can happen is that your code is as bad (or as good) as you wrote it.
Thank you for clarifying this point. How stringent are they at enforcing the Student criteria? i.e. Do they require verification of student status, similar to the way MathWorks do with the student version of Matlab?

Dave

#### n9352527

Joined Oct 14, 2005
1,198
No enforcement whatsoever, you can go to Microchip site and download the C18 for free. It will function fully (all optimisations on) for 30 days after installation, and after that time it will disable _one_ optimisation only, which is the procedural abstraction.

Procedural abstraction scans the object code and replaces code sequences that appear multiple times with functions, resulting in smaller code size that is slightly slower than the original due to the function calling overhead. The effect of disabling this optimisation is not that severe, properly structured good code might see a few percents reduction in size.