1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

AVR or PIC

Discussion in 'Microcontrollers' started by beginer electroner, Aug 5, 2006.

  1. eblc1388

    eblc1388 Active Member

    Joined:
    Jan 25, 2005
    Messages:
    2,228
    Likes:
    18
    Location:
    UK
    Last edited: Aug 21, 2006
  2. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,228
    Likes:
    641
    Location:
    Derbyshire, UK
    With VERY minor modifications, turn off the comparators, alter the header and config fuse settings, and change the GPR start address - the 628 was the replacement for the 84 last century, but people seem to keep in in production by ordering the long obselete 16F84?.
     
  3. Tarsil

    Tarsil New Member

    Joined:
    Jul 1, 2006
    Messages:
    290
    Likes:
    0
    Location:
    Timisoara, Romania
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. Tarsil

    Tarsil New Member

    Joined:
    Jul 1, 2006
    Messages:
    290
    Likes:
    0
    Location:
    Timisoara, Romania

    Hmm .....AVR uC are ofering same features at a much lower cost.
    What's the catch?:confused:
    Is any? ...aside of a biger intruction set.
     
  6. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,228
    Likes:
    641
    Location:
    Derbyshire, UK
    Both devices have advantages and disadvantages, choose which you think looks easiest!.
     
  7. Tarsil

    Tarsil New Member

    Joined:
    Jul 1, 2006
    Messages:
    290
    Likes:
    0
    Location:
    Timisoara, Romania
    Can u give some details about how this is done pls?
     
  8. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,228
    Likes:
    641
    Location:
    Derbyshire, UK
    Just check any of my tutorials, the header changes and GPR start address are at the beginning, and the lines to disable the comparators are clearly commented. This is the beginning of my LCD tutorial, I've marked the relevent lines in red.

    There used to be a migration document at MicroChip, but it's from so long ago I can't find it there any more?.

    Code (text):
    ;LCD text demo - 4 bit mode
    ;Nigel Goodwin 2002

    [COLOR="red"]   LIST    p=16F628        ;tell assembler what chip we are using
        include "P16F628.inc"       ;include the defaults for the chip[/COLOR]
        ERRORLEVEL  0,  -302    ;suppress bank selection messages
        [COLOR="red"]__config 0x3D18            ;sets the configuration settings (oscillator type etc.)[/COLOR]




            cblock  [COLOR="red"]0x20[/COLOR]           ;start of general purpose registers
                count           ;used in looping routines
                count1          ;used in delay routine
                counta          ;used in delay routine
                countb          ;used in delay routine
                tmp1            ;temporary storage
                tmp2
                templcd         ;temp store for 4 bit mode
                templcd2   
            endc

    LCD_PORT    Equ PORTA
    LCD_TRIS    Equ TRISA
    LCD_RS      Equ 0x04            ;LCD handshake lines
    LCD_RW      Equ 0x06
    LCD_E       Equ 0x07

            org 0x0000

            [COLOR="Red"]movlw  0x07
            movwf   CMCON           ;turn comparators off (make it like a 16F84)[/COLOR]
     
     
  9. ThermalRunaway

    ThermalRunaway New Member

    Joined:
    Apr 9, 2005
    Messages:
    895
    Likes:
    4
    Location:
    South Wales, UK
    I think the reason for this is that a lot of existing projects use the old 16F84 and that's why beginners still get it in their heads to use them. Actually, if you try to get information about the 16F84 on Microchip's website they warn you that it's obsolete and they advise you to order the 16F628 instead.

    Brian
     
  10. samcheetah

    samcheetah New Member

    Joined:
    Dec 30, 2003
    Messages:
    872
    Likes:
    0
    Location:
    Pakistan
    do you have a link of such a page that tells you to use the F628 instead of the F84?

    actually i am asking because the page http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1335&dDocName=en010229 tells you to use the F84A instead of the F84.
     
  11. ThermalRunaway

    ThermalRunaway New Member

    Joined:
    Apr 9, 2005
    Messages:
    895
    Likes:
    4
    Location:
    South Wales, UK
    I've just checked their website and you're right it does suggest the 16F84A instead. I'm sure I read it on there somewhere though. Maybe I'm mistaken, as I can't immediately find where I read that on their website. Either way it's good advice to use the 628 :eek:

    Brian
     
  12. keithK

    keithK New Member

    Joined:
    Aug 6, 2006
    Messages:
    9
    Likes:
    0
    Location:
    Plano, TX
    Also consider 16F88. More info here.
     
  13. Tarsil

    Tarsil New Member

    Joined:
    Jul 1, 2006
    Messages:
    290
    Likes:
    0
    Location:
    Timisoara, Romania
    Last edited: Aug 21, 2006
  14. Tarsil

    Tarsil New Member

    Joined:
    Jul 1, 2006
    Messages:
    290
    Likes:
    0
    Location:
    Timisoara, Romania
    Th..and the tutorials come in handy.
     
  15. philba

    philba New Member

    Joined:
    Mar 12, 2006
    Messages:
    1,886
    Likes:
    8
    Location:
    Seattle
    one minor point, even the 16F628 is old, microchip recommends the 16F628A which is even cheaper than the 16F628. no differences to worry about unless you are writing programmer code.

    And, yes, I totally agree that 16F88 is a much better chip to learn on. It has a slightly different pin-out but is much nicer in many ways.
     
  16. mramos1

    mramos1 Active Member

    Joined:
    Sep 15, 2005
    Messages:
    2,403
    Likes:
    9
    Location:
    Boynton Beach, Florida USA
    Philba.

    I learned that too after getting the 628A and making an ICD2..

    16F88 is my choice too. But I am doing ICD Otherwise, the 16F84 works fine far as burn and test it. It draws more power, but works fine and there are a lot of website with projects.
     
  17. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,228
    Likes:
    641
    Location:
    Derbyshire, UK
    The whole point though is the 16F628 is a drop-in replacement for the 16F84, just requiring the VERY minor code changes I gave above.

    As for MicroChip listing the 84 as obselete?, they did for many years, but it was so long ago that it's probably been removed now?. (You don't get a note on the Ford site telling you to buy a Ford Focus instead of a horse and cart :D ).
     
  18. Nick9494

    Nick9494 New Member

    Joined:
    Jul 4, 2006
    Messages:
    7
    Likes:
    0
    Been a few posts since a PIC vs AVR rummble so here are my 2 cents worth on PIC vs AVR...

    I started in Z80 assembly and later dabbed in the mindf!ck known as 8086 assembly (bank switching anyone?) before discovering the beauty and pleasure of writing for the 68000. I came across pics when I got sick of the Z80 + 2764 + 6264 + glue to do what were relatively simple tasks, then I found the AVR's. Hate to say it but I find writing assembly for PIC akin to stabbing myself in the face (just like in the 8086 days but for a different reason), Except its not even that efficient, because I have to move the knife into the working register first (movlw KNIFE), before I can stab myself (movwf FACE). Even makes the 6502 with its 3 working registers look like it has something going for it.

    Sure 35 instructions is less, but it is not nescessary a case of less is more, I'm tighter and neater in AVR than PIC as to do the same job in a pic can take more instructions.

    But at the end of the day, it is a case of what you are comfortable with, what is available to you and what you are trying to do. Most microcontrollers these days can wack the bejesus out of a Commodore 64, PC-XT or even a PC-AT and although I have nothing against the PIC, I must say I prefer to go bare metal with the AVR anyday, particularly where there is any degree of algorithm or computation required.

    Nick.
     
  19. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,228
    Likes:
    641
    Location:
    Derbyshire, UK
    Or it can take less, depending what the task actually is?.

    Your background (Z80 and 8086) is probably more biased towards AVR code than the PIC?, the VERY CISC instruction sets of the Z80 and 8086 are more like the AVR than the PIC.

    I came from a 6502 background (and a little 68000), and it's fairly easy from 6502 to PIC.

    Bear in mind, one HUGE difference is the PIC's Harvard architecture, which does make it quite different from almost any other processor - but, in some ways, is an advantage?.
     
  20. geko

    geko Active Member

    Joined:
    Mar 2, 2006
    Messages:
    411
    Likes:
    28
    Location:
    Rutland, England, UK
    I've heard a saying that "a Fortran programmer can write Fortran programs in any language" and something similar about C programmers and Perl.

    Your coding mindset tends to get optimised for the language or in this case processor you are familar with so when you move to a different processor with a fundamentally different architecture it can seem like a piece of junk in comparison and coding hard work.

    Inevitably some feature or functionality of one processor will be poor in comparison to another but I don't believe that the overall difference between good and bad in the PIC vs AVR debate is as big as some make it out to be.

    Pete
     
  21. Nick9494

    Nick9494 New Member

    Joined:
    Jul 4, 2006
    Messages:
    7
    Likes:
    0
    If by Harvard Architecture you mean separation of the program and data memory then there is no difference between the PIC and AVR, they are both Harvard processors. However the other 40 pin beasties including the 64 pin 68k (oooo I love those ceramic 64pin dips:p ) are not. Separation of data and program memory should allow a perfomance increase. The AVR executes nearly everything except conditional branches, literals and hardware multiplies in one clock cycle (others generally take 2), The PIC (like the Z80) seems to need at least 4 cycles to do anything.

    I will admit that my approach to coding is influenced by the other processors and I prefer the flexabilty afforded by the AVR architecture, just my personal choice:) . I like being able to do anything to any register with any other register(sounds very orthogonal and RISC like doesn't it :cool: - except R0-R15 won't do it with any old literal that comes in from the program space, R16-R31 are more promiscous in this regard:eek: ) as well as having the freedom of otherwise RISC style addressing modes. The AVR architecture was developed by two Norwegian sudents (Alf and Vegard from memory) and AVR allegedly stands for "Alf and Vegard's RISC processor".

    I'm sure the study that concluded most CISC addressing modes aren't used is because they were looking at output generated by compilers that weren't designed to take advantage of them.:confused: This is all well and good, design a processor to suit the compiler, save several tens of thousands of transistors as well as several thousand manhours and some tenths of grams of silicon.

    My advice for the novice is to just chose a microcontoller and start some where. Once you have built up some experience you can try something else. I've written for half a dozen diffferent cores and whilst there are differences between them, there are also a lot of concepts that remain unchanged. Not everything you learn will be portable but a great proportion of it will be. Don't expect to see many 5 or 6 letter nemonics for instructions in other processors though... ;) In time you will develop your own tastes and who knows you may decide pics and avrs are pooh and go off with ST7's ARM's or the next as yet unreleased product.:D

    N.
     

Share This Page