PICKit2 Command Line Setup in CCS Compiler IDE
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.