■ FIGURE 6. Find the PICkit 2
Command Line.
■ FIGURE 5. Enter PICkit 2
Command Line.
pk2cmd.exe file that was included in
the zip file you downloaded. You
don’t have to know where it is for this
step but, when you click on the “Next
>” button, the screen in Figure 6 will
pop up asking for the file location.
You have a choice in how you
want to find the “pk2cmd.exe” executable file. You can have MicroCode
Studio search for the command line
automatically, or you can manually
select it yourself if you remember
where you put it on your hard drive.
The manual option is a lot faster.
to the PICkit 2, prior to starting the
PICkit 2 command-line executable.
The command-line options include
both the PICkit 2 and MicroCode
Studio format options, combined. It
took me several tries to get this right.
The line you enter may vary from what
I show below, depending upon how
you want to use the PICkit 2.
-PPIC$target-device$ -F$hex-file
name$ -E -M -Y –Y
COMMAND-LINE
OPTIONS
The next step I’m going to
describe is the most critical and
the most difficult, because these are
the command-line options that will
transfer the PIC you are using and the
.hex file that the compiler just created
■ FIGURE 7. Command Line
Option Window.
The “Readme for PK2CMD.txt”
file that downloaded with the
“pk2cmd.exe” file explains all
the PICkit 2 command-line options. I
highly suggest you read this over. The
command-line options I ended up with
are shown entered into the screen in
Figure 7. Let me explain my choices.
The –P option selects the PIC, but
I wanted MicroCode Studio to pass
that on from its selection window.
MicroCode Studio offers that detail as
a parameter “$target-device$,” but it
doesn’t include the “PIC” in front of
the number (e.g., it shows simply
“16F690,” instead of PIC16F690) so
you have to type that in. This gives us
the “–PPIC$target-device$” part of
the command-line option.
I’m using the PICBASIC PRO
compiler, and the –F option selects the
.hex file from the compiler created.
MicroCode Studio offers the path to
the compiled and assembled .hex
files through a parameter called “
$hex-filename$.” This part
of the command
line thus becomes
“-F$hex-filename$.”
The other command-line options
are where you may
modify the setup that
■ FIGURE 8.
The pk2cmd.exe
Programming Screen.
I have. I first added the –E option,
which directs the PICkit 2 to erase the
PIC first, before loading a new
program. Then I added the –M option,
which directs the PICkit 2 to program
all locations, including program
memory, the configuration, the
EEPROM, and the ID memory. You
can do these separately if you
want just the program memory. The
different command-line options for
these other choices are explained in
the “Readme for PK2CMD.txt” file.
The –Y is the last option I chose
to include in my command line, and it
verifies the device. I would have
thought –V would have been for
verify, but it does something else,
which is another reason why I
recommend reading the README file.
As with the –M command, I chose to
have everything verified. The program
memory, configuration, EEPROM, and
ID locations are all verified. You can
do these individually, as well.
You will notice that I added a second –Y to the end of the command
line. This is strictly for a delay. When
the command line starts from within
MicroCode Studio, it actually opens a
separate DOS command-line window
as shown in Figure 8, then performs
the erasing and programming routines, and then verifies the locations.
After the verification is complete, it
quickly closes the DOS command
window that it had opened. The
problem is it closes the DOS
command-line window so quickly, that
I could not see if the “Program
Succeeded” and “Verify Succeeded”
messages were displayed. Adding the
second –Y provided enough delay to
allow me to read them.
I later found out that the –M
command actually erases the part
and verifies it also. So a “Program
Succeeded” message means the part
was also successfully erased and verified. I prefer to see the actual “Erasing
Device” and “Verify Succeeded”
messages so that is why I still include
the –E and –Y. Therefore, if you add all
this up, my command line actually
erases the part twice, programs in
68
January 2008