Menu

PICkit2 as AVR Programmer

2020-02-13
2020-02-16
  • William Roth

    William Roth - 2020-02-13

    This is for Stan and anyone else wanting to eliminate the bootloader on AVR Chips . Recently Stan posted on another thread ....

    "I don't know if icsp works the same way for avr as pic. Seems if uchip usb dev boards have no bootloader then a usb to ttl converter connected to a 328p should work the same...or am I missing lots of stuff."

    Generally speaking , a USB/TTL converter can only be used to program a chip with a bootloader. Most modern Microchip Dev boards have a PKOB (PICKit ON BOARD) PRogrammer that is basically another PIC that acts like a PICKIT.

    To program an UNO with no bootloader or a bare Mega328P on a breadboard with no bootloader, a programmer is necessary. This can be one of many different programmers but can also be a Pickit 2.

    An UNO or a bare m328p can be programmed from GCB using a Pickit 2. There is an entry in the Programmer Preferences titled "AVR Chips using PICkit2". However there is a typo in the commandline preferences.

    The command line preferences read: -c pickit2 -p AT%chipmodel% -U flash:w:"FileName":i
    It should instead read...... -c pickit2 -p AT%chipmodel% -U flash:w:%FileName%:i

    The connections from the PICKIT 2 to the UNO are as follows.

    PK2            UNO 
     .................................
     Pin 1  = >   ICSP Pin 5    Reset 
     Pin 2  = >   ICSP Pin 2    5V
     Pin 3  = >   ICSP Pin 6    GND  
     Pin 4  = >   ICSP Pin 1    MISO
     Pin 5  = >   ICSP Pin 3    SCK
     Pin 6  = >   ICSP Pin 4    MOSI
    
     Alternative Connection method
     PK2            UNO
     ....................................
     Pin 1  = >   Reset 
     Pin 2  = >   5V
     Pin 3  = >   GND  
     Pin 4  = >   Digital 12    MISO
     Pin 5  = >   Digital 13    SCK
     Pin 6  = >   Digital 11   MOSI
    

    After the connections are made and the PK2 is powered up
    the connections can be tested from within Synwrite/GCB by
    clicking on GCBasic => AvrDude GUI.

    At the top left select programmer as Microchip Pickit 2. The Port should be USB.
    baud rate should be blank.

    At the top right click on "Detect" . The output window should report

    : avrdude -u -c pickit2 -P usb -p m8
    Detected 1e950f = ATmega328P

    Now the GUI can be closed and the UNO Programmed with the PK2 set as the
    programmer in Programmer Preferences.

    Note: The PICKit 2 will not power the UNO after programming. An external power source
    should be used and can be connected during programming.

    Warning ! ....... Programing the UNO with this mehhod will erase the bootloader on the m328p.

    However the PICKit2 can also burn the bootloader back on if needed.

    Enjoy

    William

     

    Last edit: William Roth 2020-02-13
  • stan cartwright

    stan cartwright - 2020-02-13

    That is very useful info, thank you for posting. Can info like this be permanent for others ie not lost in time and hard to find on the forum?
    Nice explanation, ta again.
    The 328p on my uno board can be 28 pin dil or a tiny square smd thing with more pins than you can wave a stick at.
    I was thinking of ordering blank 328p from??? ebay? :)
    I suppose I prioritise things and this on the list...after I sort my lander prog which is doin' my head :)

     
  • stan cartwright

    stan cartwright - 2020-02-13

    "Generally speaking , a USB/TTL converter can only be used to program a chip with a bootloader. Most modern Microchip Dev boards have a PKOB (PICKit ON BOARD) PRogrammer that is basically another PIC that acts like a PICKIT."
    In software as I only see the usb and pic.
    It was a crap chip anyway...not enough ram to run an oled.
    edit wrong pic, it's the other one.

     

    Last edit: stan cartwright 2020-02-13
  • bed

    bed - 2020-02-14

    Maybe I could transfer this fine Article to our Homepage.
    Btw: Even I am posted very seldom in the last months, I am still reading and hopefully come more active next couple weeks )

     
    • stan cartwright

      stan cartwright - 2020-02-14

      Hi bed. I think your gcb web home page is very good.
      Would you like some of my projects to show things that gcb can do?
      A mp4 file or youtube link address ?

       
      • bed

        bed - 2020-02-15

        Thanx.
        Of Course, for the showcase i.E.
        Simply email me.

         
        • stan cartwright

          stan cartwright - 2020-02-15

          I will try to do something that looks impressive :)

           
  • Anobium

    Anobium - 2020-02-14

    The post, by Bill, is a great post.

    I would like to on the Website and in the Help.

    :-)

     
  • mkstevo

    mkstevo - 2020-02-14

    Thanks Bill.
    If I need to program a 328 or other type of Atmel device, I'll find this really useful.

     
  • William Roth

    William Roth - 2020-02-14

    To all,

    Before posting this as an article please allow me to add some more info, Specifically concerning the fuses and how to change them.

    For example , you may want to use the internal OSC on an UNO or a bare m328p. This will free up the 2 IO pins required for the crystal. I have this running on a bare m328p on a breadboard right now all programmed with GCB and a Pickit 2. The internal OSC is not a accurate as a PIC but it can be after it is tuned. I am working on the tuning process as I write this.

    Another thing to note is that the AVR processor operating at 8MHz executes instrucions as fast as a PIC operating at 16mhz. This reduces power requirements and is excellent for battery operated projects and extended battery life.

    One other thing to note is that the Pickit2 programmer like many others cannot do HV Parallel programing, meaning that if you "brick" an AVR by setting the fuses incorrectly it cannot recover the microcontroller. I bricked one already in experimenting with all of this as I am not an AVR expert. However I made a cheap HV Recovery Programmer with an UNO and a few resistors and a single NPN transistor and was able to successfully recover the chip. I wil also provide the info on how to do this as time allows.

    William

     

    Last edit: William Roth 2020-02-14
    • stan cartwright

      stan cartwright - 2020-02-15

      don't break a leg!
      Take time. Again thanks. Gcb is open source and people like you William put much into it.
      Respect to all contributors to Gcb. The hardware device libs are so useful.
      I wouldn't know where to start otherwise.

      Little gems like your info are like gold. I've spent ages looking up past posts...not fun.
      And do I need to go to github for latest gcb stuff? ...not moaning.

       
  • bed

    bed - 2020-02-15

    Thumbs up!
    Yes, I will wait, as I do not time for it next week anyway

     
    • stan cartwright

      stan cartwright - 2020-02-15

      It must take effort to make a web page for gcb.
      It is appreciated.
      Whatever your projects...may the force be with you.

       
  • stan cartwright

    stan cartwright - 2020-02-15

    I read a 328p does an instruction every clock cycle but pics do an instruction every 4 clock cycles
    so #chip 328p,16 will be as fast as #chip 18f25k22,64. I probably got it wrong as usual.

     
  • stan cartwright

    stan cartwright - 2020-02-15

    I like the usb uno/nano cos you can use the gcb teminal easy to serprint data.
    not tried with uchip usb boards.
    Using just a chip is not so easy I guess.

     
  • William Roth

    William Roth - 2020-02-15

    Using just a chip on a breadboard is mostly all I do. It is not hard at all if you follow the datasheet and get the connections right. Even with an AVR.

    For a Mega328p I connect a 16MHz crystal & the caps to the XTAL pins, put a 10K pullup on the reset pin, and connect the PK2 to the proper SPI pins and to the reset pin. Then good to go.

    Diagram is attached

    William

     
  • stan cartwright

    stan cartwright - 2020-02-16

    The circuit is saved. Thank you William.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.