Skip to content

PICKit2 Command Line Setup in CCS Compiler IDE

January 2, 2008

Microchip recently released a command line application for programming PIC chips with the PICKit2 device programmer . (It is called pk2cmd and there are links near the bottom of the page.)

I wanted to configure this for use with the CCS compiler IDE. After a few minutes of searching on Google for an answer, I didn’t find one.  So I set about figuring it out.  Here’s my solution:

The CCS Compiler allows a user to add buttons to execute 3rd party applications under the “Options|Tools” menu item.

Open this dialog box and in the dialog box, under “Name” add the name, e.g. PICKit2. Under “Usage” use the drop down menu to select where you want the new button to appear.  I added one for both “Tools Menu” and “Compile > Program Menu.”

In the “Command” box, you need something like this: “C:\Program Files\Microchip\PICkit 2 v2\pk2cmd.exe” “-P%D”  “-F%H” “-M” “-h3”

You need to add the path above to your windows “PATH” variable (under “My Computer|Properties|Advanced|Environment Variables”–I had to log out and log in for the changes to take effect.)

The %D parameter is the device name including “PIC”, e.g. PIC16F648A.  “-M” indicates that the chip is to be erased before programming; %H is the name of the hex file to program to the PIC chip.  Finally, “-h3” tells the application to wait 3 seconds before exiting.  This is a great feature as the CMD window opened by the application closes immediately when execution completes. Without the delay, you don’t get to see any of the output messages.

Be sure to read the Readme file that comes with pk2cmd.  There are additional command options for reading from the device, powering the device, etc just like the GUI interface for the PICKit2.

Hit the “Apply” button.  Be sure to save the profile by hitting the green disk “Save” button to the right of the “Tools” menu, again, under the “Options” menu. If you don’t do this step, you won’t have any custom buttons when you restart.

I hope this helps.

Advertisements
3 Comments leave one →
  1. enrique permalink
    September 15, 2009 3:05 pm

    Hello, I`m traying to conect ccs to PK2CMD, in windows XP mode, but I make all steps, but when I tray to program a pic one black window appears one second, and dissapear and de pic isn`t recorded

    Like

  2. October 2, 2009 9:25 am

    Enrique-

    Try running it from within a cmd window rather than double-clicking the python file in a file browser. (START->Run->cmd.exe). Hope this helps.

    SH

    Like

  3. August 18, 2012 2:10 am

    @enrique and to whom it may apply: Copy PK2DeviceFile.dat to project file directory.

    Like

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: