PDA

View Full Version : Compile and Program help using PICKit2



ozarkshermit
- 4th March 2009, 03:25
Hi all

I'm still learning how to use PBP - after using only assembly.

I can't seem to get the compile and program feature to work - (or program only for that matter). What I end up doing is compile in PBP, then exit, and import and program the hex file using PICKit directly. That works fine. When I try to use Compile and Program, MCS searches for the PICKit , but does not seem to find it - it just stops and does not program. The proper device is selected - in this case a 16f870. The PICKit is plugged in to the USB port, and the chip is inserted into the programming socket.
From the Compile and Program Option, I have PICKit selected as the default programmer.

I'm missing something simple - please help.

Ken

Archangel
- 4th March 2009, 05:15
Hi Ken,
This just got discussed recently, and I think this is the link:http://www.picbasic.co.uk/forum/showthread.php?p=68368
Welcome to the forum.

ozarkshermit
- 4th March 2009, 05:27
Thanks . . .

Yes, I found that thread after some more searching. Still don't have it quite right I guess, but I'll keep trying.

Ken

Archangel
- 4th March 2009, 08:33
I have not even tried to make it work as I like the pickit2 software as is. I open the pickit2 software and MCS, compile from MCS and load from PICkit2.

ozarkshermit
- 4th March 2009, 14:41
At this point I agree. I have been pulling my hair out trying to get this to work - must be missing a - or $ or something.
Anyway, to h*** with it. I will stick to using the PICKit software - like you do and I have been doing.

LOVE Pic Basic Pro however !

Ken

Archangel
- 7th March 2009, 05:31
Ok this works, I just set mine up Thanks to Darrel Taylor:
http://www.picbasic.co.uk/forum/showthread.php?p=68368

biggej
- 8th March 2009, 23:09
Ken,
My settings are a bit different than Darrel's but may have required a download of a command processor from Microchip.
In the program filename box I have pk2cmd.exe
The path should point to your "pickit 2 v2" directory which is likely
C:\program files\microchip\pickit 2 v2
My parameters string is

-PPIC$target-device$ -F$hex-filename$ -E -M -Y -Y

This works with or without the PicKit program running as it brings up a batch programming window. The -Y -Y causes the verification to run twice just so you can see the results of programming before the batch window closes.
I usually run the PicKit program also so I can use its reset MCLR function to start the code running in the pic.
Hope this helps,
Jim

ozarkshermit
- 9th March 2009, 01:54
First of all - thanks to all who have responded and made suggestions on this.

I simply cannot get this to work -

I went so far as printing out the page that Darrel posted with his step - by - step instructions, and - as far as I know - after three times - followed them to the letter.

Obviously not - all that happens is the project compiles, there is a momentary screen flash after successful assembly - then nothing, just success at compiling. I tried Jim's code as well - same thing.

Also deleted previous attempts at selecting the programmer , so as to start from scratch -

At first MCS could not find the PICKit folder, - I changed to finding it automatically, it then found the PICkit folder - but still no success.

I also re-extracted all the PICKit2 Command Line Interface files from Microchip's site to the PICkit folder - . . .twice

Anyway - - thanks to all - - I do not intend to "beat this to death" - - I'm perfectly content to continue doing the extra step using PICkit software separately. It works fine, and that is basically all I want.

Thanks again

Ken

Darrel Taylor
- 9th March 2009, 04:43
I'm perfectly content to continue doing the extra step using PICkit software separately.
Bahhh, that's quiters talk. :eek:

Troubleshooting step #1.
Open a DOS window (Start | Run... | cmd).
Paste this line into the window (right click | paste) ...

"c:\program files\microchip\pickit 2 v2\pk2cmd.exe"
Include the quotes when pasting. Then press enter.

If the command line interface is in the correct place, it should fill your window with the HELP page.

If it does ... on to troubleshooting step #2.
<br>

Chris Barron
- 9th March 2009, 13:08
First of all - thanks to all who have responded and made suggestions on this.

I simply cannot get this to work - Thanks again

Ken



I haven't tried but it was something I have been meaning to do. Is everyone aware that you don't need to continually reload the software hex within pickit2, but that it does it automatically when you press the program button on the pickit hardware.

I normally compile using PBP, and when I get the 'complete' message at the bottom of Explorer window then press the button on the pickit2 hardware. You only have to open the pickit2 software and load the hex you're working with once per session.

I guess where it gets more complicated is if you're developing several different programs and want to pick the appropriate hex each time.

ozarkshermit
- 10th March 2009, 03:33
SUCCESS (I think)

I changed the "Programmer Filename" from pk2cmd.exe as was suggested to : PICkit2v2.exe - (which was described under PICkit2v2 Properties - version - Internal name) as PICkit2v2.exe. Now when I compile and program, after assembly is complete, the PICkit2 screen pops up, and I auto import the hex file and program. I'm not sure if the PICkit screen is supposed to pop up or not, It seems like an extra step - but then I'm not sure how it is SUPPOSED to work, but this eliminates exiting and going to that screen - - -

Ken

Darrel Taylor
- 10th March 2009, 04:13
No, that's not the way it works. Must have missed a few "Letters" in that printout.

Did you do the troubleshooting step?
<br>

Archangel
- 10th March 2009, 05:30
OK Darrel, I did it exactly the same way as osarkhermit did, I do not have a file called pk2cmd.exe in my computer anywhere. The executables I have are PICkit2 in the PICkit2 directory and PICkit2V2 in the PICkit2V2 directory. The first opens the programmer on the right the other opens the one on the left.<br><br>
http://www.picbasic.co.uk/forum/attachment.php?attachmentid=3248&stc=1&d=1236666441
<br> And this fails in Run: c:\program files\microchip\pickit 2 v2\pk2cmd.exe But the path is correct except pk2cmd.exe does not exist .

Darrel Taylor
- 10th March 2009, 06:05
I do not have a file called pk2cmd.exe in my computer anywhere.
After you pointed to the other thread, I thought for sure you got it right Joe.
http://www.picbasic.co.uk/forum/showpost.php?p=68386&postcount=23

The pk2cmd.exe program comes from the "PICKit2 Command Line Interface" which must be downloaded and extracted to your PICkit 2 V2 folder.
http://ww1.microchip.com/downloads/en/DeviceDoc/PK2CMDv1-12.zip

If you didn't download it, or extracted it to the wrong place, it definitely can't run.

That's why I gave the Troubleshooting Step above.
With one simple test, you can determine if the file is there or not.

If it's not there, download it.
<br>

Archangel
- 10th March 2009, 06:21
Yes I found it on the Disc in it's own directory, copied it to where you said and set it up as instructed. I then ran from the command line as instructed and saw a dos window flash quickly by. Now if I run compile and program I see the dos window flash by, I do not see any activity on my programmer, this however may not be a problem as described here as I Skanked my whole windoze system the other night and am still reinstalling programs to make nice again, I may have to reinstall pickit2 too. Note to self: never delete user.dat from windows :D
edit:
OK it works, but only if I first open the PICkit2 program and select the correct chip and file first, then clicking compile and program will update the PIC firmware with 1 click. The script is copy pasted from your example. WIN98se, PBP2.50 MCS+ 3.0.0.5 . It may be a WIN98 USB issue.

ozarkshermit
- 10th March 2009, 14:51
OK - It's Alive - - -

I guess I missed something earlier - anyway it works.

Thanks to all

Ken