Close
0%
0%

Microchip's PICkit 2 as an Atmel STK500 programmer

PICkit can be used as a PIC Programmer, Serial to USB converter, Logic Probe, Logic Analyzer, but also as an AVR Programmer for Atmel MCUs

Similar projects worth following
How to program Atmel microcontrollers using a Microchip programmer.

PICkit 2 programmer (from Microchip) together with two free software components, com0com and pk2avrisp.exe, can be used to emulate an STK500 programmer (from ATMEL). This way, the PICkit 2 can be used to program not only Microchip microcontrollers, like PIC, but also Atmel microcontrollers, like AVR.

Here, an ATtiny13 produced by Atmel will be programmed from BASCOM-AVR, using a PICkit 2 programmer produced by Microchip. Also tested and working with ATmega8 and ATmega328.

How it works

In a normal data flow, when we have the physical STK500 programmer board, the microcontroller code (firmware) produced by the compiler is sent to STK500 software. The STK500 software will produce ISP commands for the STK500 board, and will transmit those commands through physical serial port COM1, to the STK500 board. Based on the received ISP commands, the STK500 board will produce the MISO/MOSI/CLK pulses required to program the Atmel microcontroller.

In order to use a PICkit instead of a STK500 board, we will hijack the ISP commands. We will trick the STK500 software to send the ISP commands to our virtual COM3 port instead of the real COM1 port.

From the virtual port COM3, the ISP commands will travel through a virtual cable inside of the com0com software, and will arrive to virtual COM4.

At the virtual COM4 we will connect another software, PK2AVRISP, which is in fact an ISP commands translator. PK2AVRISP will translate the STK500 ISP commands into PICkit commands. From here, the PICkit commands will travel through a real USB port, and the commands will arrive to PICkit 2.

PICkit will execute these translated commands into MOSI/MISO/CLK pulses necessary to program our Atmel microcontroller.

Download software components

Install downloaded software

1. Install BASCOM-AVR

BASCOM-AVR is an IDE that allows to write programs in BASIC language and compile them for AVR microcontrollers like ATtiny13, ATmega8, MEGA328 (last two also used in Arduino boards) and other Atmel MCUs. BASCOM-AVR is a copyrighted commercial program created by MCS Electronics company. MCS Electronics offer a free BASCOM-AVR Demo version for hobby, educational and noncommercial use. This version is limited to less then 4K of compiled code. Usually, 4k is enough for noncommercial use. If you need more, you can buy the unlimited version.

Unzip downloaded file 'bcavrdmo.zip', then run 'setupdemo.exe'. Follow the installer instructions

2. Unzip PK2AVRISP.zip

PK2AVRISP is a program that will intercept the ISP programming commands destined to STK500 AVR programmer, and will translate them into commands for PICkit programmer. This way, we can later use an PICkit 2 programmer instead of a STK500 programmer. PK2AVRISP is free (but not open), and it was written by kcsoft.

Just extract the 'PK2AVRISP.exe' from the 'PK2AVRISP.zip', it does not need an installation.

3. Install com0com

com0com is an open source software that can create pairs of virtual COM ports linked together, written by vfrolov (Vyacheslav Frolov). com0com will be used to redirect all ISP commands from the IDE to the PK2AVRISP.exe translator.

To install com0com is a little tricky, because the virtual COM ports drivers are not digitally signed for Windows. com0com can be used without problems with Windows XP, but for newest Windows flavors, like Windows 7, we need to disable the digital signature enforcement for drivers. The most easy way to do this is by restarting Windows and boot into disabled enforcement mode.

Restart your computer, and during the computer restart continuously pump the F8 key until you arrive to the following boot screen:


Using Up and Down keyboard arrows, highlight the entry "Disable Driver Signature Enforcement", then press Enter to boot into disabled enforcement mode.

This mode will stay active only until the next Windows restart. Please remember to boot into this mode each time you need to use com0com.

Now we can start installing com0com:

  • Unzip 'com0com-3.0.0.0-i386-and-x64-unsigned.zip'
  • Right click on 'setup.exe' and run it as Administrator
  • At the step 'Select components to install:', uncheck the last two lines:
    CNCA0 <-> CNCB0
    COM# <-> COM#
  • At the Windows Security warning dialogue, allow...
Read more »

  • 1 × PICkit 2 Microchip programmer
  • 1 × ATtiny13 Microprocessors, Microcontrollers, DSPs / ARM, RISC-Based Microcontrollers

  • So far, it didn't work with AVR Studio 5 or Atmel Studio 6

    RoGeorge08/02/2015 at 16:52 0 comments

    :o(

    3D Printing AVR Arduino Art Audio Automation BeagleBone Bluetooth Cameras Clock Drones Environment Hardware IoT LED Medical Music Radio Raspberry Pi Remote Control Robotics Rockets Satellites Science Security Software Virtual Reality Wearables

  • Tested and working with AVR Studio 4 and Windows XP

    RoGeorge08/02/2015 at 16:51 0 comments

    Tested and working with AVR studio 4 and Windows XP. The AVR Studio 4 programmer may be either STK500 or AVRISP. If you get a verify error message after programming, go to the Program tab and uncheck Erase device before programming, then go to Auto tab and uncheck Erase device, Check signature and Enable fuse warning.

    In my setup, the problem came from the fact that after an erase, the program sequence start too fast. That is why I unchecked the above boxes and manually start the following sequence:

    • Erase Chip
    • Program
    • Read
    • Verify

    By manually execution, there is enough pause between erase and program steps, so all operations complete successfully.

    3D Printing AVR Arduino Art Audio Automation BeagleBone Bluetooth Cameras Clock Drones Environment Hardware IoT LED Medical Music Radio Raspberry Pi Remote Control Robotics Rockets Satellites Science Security Software Virtual Reality Wearables

View all 2 project logs

Enjoy this project?

Share

Discussions

K.C. Lee wrote 08/05/2015 at 12:37 point

Any possibility of using a signed drivers?  Turning off Windows signing is not good for security.

http://freevirtualserialports.com/  is a signed driver, closed source, but $0 "free" software for creating/emulating serial ports under current Windows.

  Are you sure? yes | no

RoGeorge wrote 08/13/2016 at 05:44 point

I don't know, but next time I will try AVRdude, since it now have support for PICkit2, as waicool20 pointed out in the comments.

  Are you sure? yes | no

waicool20 wrote 08/05/2015 at 11:02 point

You do know that AVRDUDE can use PICKIT2 as a programmer right? That's what I use.

  Are you sure? yes | no

K.C. Lee wrote 08/05/2015 at 12:29 point

Atmel Studio does not support it or other programmer automatically.  You'll need to add it to the Atmel Studio GUI or run it externally.

  Are you sure? yes | no

waicool20 wrote 08/05/2015 at 12:36 point

Why not just run it externally then? It's much more reliable than creating your own hack, a simple makefile could ease up the process

  Are you sure? yes | no

K.C. Lee wrote 08/05/2015 at 12:39 point

I am not the author, but IMHO you are entirely missing the point for the hack.  Some of us like to use Atmel Studio and want to have integrated support for non-Atmel programmer.  Make file is missing the point of using GUI.

  Are you sure? yes | no

RoGeorge wrote 09/06/2015 at 20:23 point

LOL, actually I didn't knew it. When I first used the described setup, a few years ago on a Windows XP, the PICkit 2 was not supported by AVRdude, and also the whole mess with the test mode and the signed drivers was not required by XP. Since then, I didn't checked AVRdude, but I will give it a try next time.

Thanks for sharing!

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates