Perhaps someone might find this helpful. I've been using PicKit3 for the past year or two. I made my own IDE configured around TextPad which I really like, due to its great speed and consistency among the other languages on my computer.
However, I decided to play around with the GCB@Syn IDE the other night, just to check it out. After some backtracking and a fair amount of scurrilous language, I was able to make it work with PicKit3. Here's how to do it. It works very well for me.
In the GCB@Syn folder, create a new folder called PicKit3. There's already a PicKit2 one in the GCB@Syn folder, and you'll basically be just imitating that.
Then get yourself a copy of PK3CMD.EXE, either by finding in the Microchip MPLAB package, or by Googling and downloading a copy. This is the command line interface software for the programmer. Copy it into the folder you just created in Step 1.
Locate the G@Stools folder in GCB@Syn. Open up the file named flashPIC.bat for editing.
REM out whatever programmer is currently shown there and add the line:
"PicKit3\PK3CMD.EXE" -p%2 -e -f%1 -m -v5
Notice that the syntax is slightly different for this compared to the PicKit2 example in the IDE, just enough to drive you nuts, as it did me for a little while...
Save the new batch file and you're all set to go!
Supposing others find this successful, maybe it could be added to the GCB@Syn package, side-by-side with the PicKit2 stuff.
Thomas Henry
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello all
New to GCBasic. Great program ! Here is my contribution to include Pickit3 in the GCB@Syn IDE flashPIC.bat file. I am using it flawlessly with a PIC-KIT3 Olimex programmer but it should work with the original Microchip PICKit3. I am assuming that MPLABX is installed on your PC.
@echo off
echo *** flashPIC.bat ***
echo.
REM This batchfile is called from G@Stool.exe if an PIC-chipmodel is detected and
REM no "FlashThis.bat" is present in the sourcefile-folder.
REM You can adapt this file to your needs.
REM %1 is replaced with the hexfile in double quotes i.e. "C:\My Folder\nice file.hex"
REM %2 is replaced with the chipmodel i.e. 16F688
REM G@Stool.exe always makes the GCB@Syn root-folder the current folder.
REM --- flashPIC code for Pickit3 :
REM --- check the location/version of java coming with your MPLABX version and adjust if needed
REM ---
set javapath=C:\Program Files (x86)\Microchip\MPLABX\sys\java\jre1.7.0_25-windows-x64\java-windows\bin
set ipecmd="C:\Program Files (x86)\Microchip\MPLABX\mplab_ide\bin\ipecmd.jar"
set pathbak=%path%
set path=%path%;%javapath%
java -jar %ipecmd% -TPPK3 -P%2 -M -F%1
REM ---
REM --- Creating "G@Stools\FlashError.txt" makes G@Stool to leave the message-window open:
REM ---
if not errorlevel 1 goto END
echo ERROR running: %0 with parameters %1 %2 %3 %4 %5 %6 %7 %8 %9 >G@Stools\FlashError.txt
echo ERROR running: %0 with parameters %1 %2 %3 %4 %5 %6 %7 %8 %9
:END
REM ---
REM --- Restore initial PATH variable and cleanup temp VAR
REM ---
set path=%pathbak%
set pathbak=
set javapath=
set ipecmdpath=
Jacques
Last edit: Jacques Nilo 2014-04-27
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Can you please confirm the version of PK3CMD.exe? Mine is 1.00.14 and this version does not seem work. Can you help as this would be better than my current method
Anobium
ERRORS.
*** makeHEX.bat ***
Great Cow BASIC (0.9 17/2/2014)
Compiling D:\MicroChip\Projects\Great Cow Basic\I2C\DS2482\DS2482_16F1937_002.gcb ...
Done
Assembling program ...
Program assembled successfully!
*** flashPIC.bat ***
Connecting...
PICkit 3 detected
Connecting to PICkit 3...
PK3Err0033:
4 bytes expected, 0 bytes received
Failed to properly connect to PICkit 3
PK3 not Connected !!!ERROR running: "C:\dev\Others\GCB@Syn\G@Stools\flashPIC.bat" with parameters "D:\MicroChip\Projects\Great Cow Basic\I2C\DS2482\DS2482_16F1937_002.hex" 16F1937
I then changed the PICKIT3 back to MPLAB mode then I got PK3Err0035: error.
I have reverted by to 'Download Pickit Operating System" mode and I then use AUTO IMPORT HEX to load the HEX when I compile.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2014-02-25
Hello Anobium,
I'm using the same version. 1.00.14, on an Windows XP laptop. It works just fine. Here's what I see:
I looked error up. Its a USB issue post XP. So, it may only work on XP?
I have windows 7 sp 2.
Any thoughts?
And, can you pop me an email please.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2014-02-25
I have used PK3CMD.EXE on my Windows 7 machine, too, with TextPad running as the IDE. I don't think it's a Windows problem. I recently switched over to an old, used XP machine just so I could keep it on the workbench, leaving my 7 machine for the upstairs.
Anyway, PK3CMD.EXE works well for me under both GC@SYN and TextPad on the XP.
I suppose I should mention that my PicKit 3 is a clone from China.
Thomas Henry
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I will have another go. Trying different ports etc. etc.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2014-02-26
Here's my setup for anyone else who is following this saga.
All of my PIC stuff is in the the folder C:\PIC.
I keep all of my GC Basic source code in C:\PIC\BASIC, sorted into various subdirectories.
I copied the GCB@SYN folder completely, with no changes, so it appears as C:\PIC\GCB@SYN.
Within C:\PIC\GCB@SYN I made a new folder called PICKIT3.
I then stored PK3CMD.EXE in C:\PIC\GCB@SYN\PICKIT3. There is nothing else in this folder.
In the folder C:\PIC\GCB@SYN\G@STOOLS is the file FLASHPIC.BAT. I modified it so it looks like this:
@echo off
echo *** flashPIC.bat ***
echo.
REM This batchfile is called from G@Stool.exe if an PIC-chipmodel is detected and
REM no "FlashThis.bat" is present in the sourcefile-folder.
REM You can adapt this file to your needs.
REM %1 is replaced with the hexfile in double quotes i.e. "C:\My Folder\nice file.hex"
REM %2 is replaced with the chipmodel i.e. 16F688
REM G@Stool.exe always makes the GCB@Syn root-folder the current folder.
REM --- Your code here: ---------------------------------------
REM Call PICpgm-programming software:
rem "PICPgm\picpgm.exe" -delay 1 -p %1
rem "PICPgm\picpgm.exe" -delay 1 -if "5PiP" -port COM1 -pic PIC%2 -p %1
rem "PICPgm\picpgm.exe" -delay 1 -if "JDM Programmer" -port COM1 -pic PIC%2 -p %1
"PicKit3\PK3CMD.EXE" -p%2 -e -f%1 -m -v5
REM Call PicKit2 command-line programming Software:
rem "PicKit2\pk2cmd.exe" -b"%G@SDir%\PicKit2" -pPIC%2 -f%1 -m
REM Call uploader for diolan bootloader:
rem "Bootloader\picboot" -r %1
REM Call mikroProgSuitePIC-programming software:
rem "C:\WinSpr\mikroProgSuitePIC\mikroProg Suite for PIC.exe" -q -w -pPIC%2 -v -f%1
REM --- End of your code. -------------------------------------
REM Creating "G@Stools\FlashError.txt" makes G@Stool to leave the message-window open:
if not errorlevel 1 goto END
echo ERROR running: %0 with parameters %1 %2 %3 %4 %5 %6 %7 %8 %9 >G@Stools\FlashError.txt
echo ERROR running: %0 with parameters %1 %2 %3 %4 %5 %6 %7 %8 %9
:END
The only change to the original is REM-ing out everything else, and adding in the PicKit3 invocation.
While running GCB@SYN I made one change to the settings. From the Menu Bar, choose RUN/Customize External Tools. Then choose the Flash Previous Made File on the left table, and delete the "stayOpen" option on the right panel.
With these changes, everything works fine for me. I hope I haven't forgotten anything!
Thomas Henry
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
First off, I believe you have to have MPLAB installed on your computer as well to use PK3CMD.exe.
Unlike PK2CMD.exe, PK3CMD.exe uses drivers in the MPLAB folders to run.
That is the major difference between the two.
Another issue is some computers USB ports have voltage issues with PICkit 3.
Within MPLAB, you need to set the drive voltage to something less than 5.0v.
4.75v usually works.
Anobium,
Verify you have MPLAB installed on your computer, which it sounds like you do.
Then try changing the voltage to lower voltage in Programmer>Settings> Power tab.
If that corrects it, then try changing the -v5 to -v4.8.
I can't test it right now but I believe that may help.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Need to set the PicKit3 to MPLAB mode, NOT PicKit Operating System Mode.
Set the voltage to 4.8v in the batch file.
But, a warning. The batch file has a hard coded voltage. This may not the correct voltage for all devices. Should people be very careful?
Cheers!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2014-02-26
I see that the flasher batch file is already set to accept command line parameters. Perhaps the voltage parameter could be sent in from GCB@Syn somehow.
I have used TextPad in the past as my IDE, and it too allows command line parameters when an external tool is invoked. But it also accepts environment variables, which I have typically used to alert PK3CMD.EXE of the the chip model.
But I will also say, that so far I've only used 5V chips, and so have never needed this flexibility.
Anyway, glad to hear you got it working now!
Thomas Henry
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The -v is optional I believe so leave it off and the device file should trigger the PICkit 3 to set the proper programming voltage level. But you won't have control over the supply voltage if want PICkit 3 to power your board.
It's best to power the PIC separately anyway and PICkit 3 should sense that.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2014-02-27
Well, it doesn't seem to be optional on my computer. If I leave it off I get a PKErr0045 error, and the flash fails. But if I include -V5, the chip flashes perfectly. This is in GCB@Syn. So, I'm going to keep using the parameter since it works.
Thomas Henry
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Did You have power to the PIC separately such as power on the breadboard?
The -v option powers the PIC during programming and after. So removing that relies on external Vdd power.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2014-02-28
I'm using the PicKit3 as a programmer only, powered only by the USB. Here's a picture of my little rig.
Having spent many hours trying to get my new pickit3 to work with pk3cmd I will resurrect the old thread to give my thoughts.
First the pickit3 seems to assume by default that you are doing in circuit programming so does not supply the power. So you have to do the -v option.
The -v option seems to require a set format #.### -v5 does not work for me.
Anyway here is my batch file that works.
I should have pointed out that I don't use the IDE. As there wasn't one when I started using gcbasic. I use notepad then drag the file over the batch file above.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello Gang,
Perhaps someone might find this helpful. I've been using PicKit3 for the past year or two. I made my own IDE configured around TextPad which I really like, due to its great speed and consistency among the other languages on my computer.
However, I decided to play around with the GCB@Syn IDE the other night, just to check it out. After some backtracking and a fair amount of scurrilous language, I was able to make it work with PicKit3. Here's how to do it. It works very well for me.
In the GCB@Syn folder, create a new folder called PicKit3. There's already a PicKit2 one in the GCB@Syn folder, and you'll basically be just imitating that.
Then get yourself a copy of PK3CMD.EXE, either by finding in the Microchip MPLAB package, or by Googling and downloading a copy. This is the command line interface software for the programmer. Copy it into the folder you just created in Step 1.
Locate the G@Stools folder in GCB@Syn. Open up the file named flashPIC.bat for editing.
REM out whatever programmer is currently shown there and add the line:
Notice that the syntax is slightly different for this compared to the PicKit2 example in the IDE, just enough to drive you nuts, as it did me for a little while...
Supposing others find this successful, maybe it could be added to the GCB@Syn package, side-by-side with the PicKit2 stuff.
Thomas Henry
Hello all
New to GCBasic. Great program ! Here is my contribution to include Pickit3 in the GCB@Syn IDE flashPIC.bat file. I am using it flawlessly with a PIC-KIT3 Olimex programmer but it should work with the original Microchip PICKit3. I am assuming that MPLABX is installed on your PC.
Jacques
Last edit: Jacques Nilo 2014-04-27
Good work. Most interesting.
Can you please confirm the version of PK3CMD.exe? Mine is 1.00.14 and this version does not seem work. Can you help as this would be better than my current method
Anobium
ERRORS.
I then changed the PICKIT3 back to MPLAB mode then I got PK3Err0035: error.
I have reverted by to 'Download Pickit Operating System" mode and I then use AUTO IMPORT HEX to load the HEX when I compile.
Hello Anobium,
I'm using the same version. 1.00.14, on an Windows XP laptop. It works just fine. Here's what I see:
Thomas Henry
I looked error up. Its a USB issue post XP. So, it may only work on XP?
I have windows 7 sp 2.
Any thoughts?
And, can you pop me an email please.
I have used PK3CMD.EXE on my Windows 7 machine, too, with TextPad running as the IDE. I don't think it's a Windows problem. I recently switched over to an old, used XP machine just so I could keep it on the workbench, leaving my 7 machine for the upstairs.
Anyway, PK3CMD.EXE works well for me under both GC@SYN and TextPad on the XP.
I suppose I should mention that my PicKit 3 is a clone from China.
Thomas Henry
I will have another go. Trying different ports etc. etc.
Here's my setup for anyone else who is following this saga.
All of my PIC stuff is in the the folder C:\PIC.
I keep all of my GC Basic source code in C:\PIC\BASIC, sorted into various subdirectories.
I copied the GCB@SYN folder completely, with no changes, so it appears as C:\PIC\GCB@SYN.
Within C:\PIC\GCB@SYN I made a new folder called PICKIT3.
I then stored PK3CMD.EXE in C:\PIC\GCB@SYN\PICKIT3. There is nothing else in this folder.
In the folder C:\PIC\GCB@SYN\G@STOOLS is the file FLASHPIC.BAT. I modified it so it looks like this:
The only change to the original is REM-ing out everything else, and adding in the PicKit3 invocation.
While running GCB@SYN I made one change to the settings. From the Menu Bar, choose RUN/Customize External Tools. Then choose the Flash Previous Made File on the left table, and delete the "stayOpen" option on the right panel.
With these changes, everything works fine for me. I hope I haven't forgotten anything!
Thomas Henry
First off, I believe you have to have MPLAB installed on your computer as well to use PK3CMD.exe.
Unlike PK2CMD.exe, PK3CMD.exe uses drivers in the MPLAB folders to run.
That is the major difference between the two.
Another issue is some computers USB ports have voltage issues with PICkit 3.
Within MPLAB, you need to set the drive voltage to something less than 5.0v.
4.75v usually works.
Anobium,
Verify you have MPLAB installed on your computer, which it sounds like you do.
Then try changing the voltage to lower voltage in Programmer>Settings> Power tab.
If that corrects it, then try changing the -v5 to -v4.8.
I can't test it right now but I believe that may help.
Chuck you are the detective! I do have MPLAB installed - can you see my computer? :-)
I will try the volume changes - as a way of approaching this would this work? As this specifies the volume.
"PicKit3\PK3CMD.EXE" -p%2 -e -f%1 -m -v4.8
Works!
Need to set the PicKit3 to MPLAB mode, NOT PicKit Operating System Mode.
Set the voltage to 4.8v in the batch file.
But, a warning. The batch file has a hard coded voltage. This may not the correct voltage for all devices. Should people be very careful?
Cheers!
I see that the flasher batch file is already set to accept command line parameters. Perhaps the voltage parameter could be sent in from GCB@Syn somehow.
I have used TextPad in the past as my IDE, and it too allows command line parameters when an external tool is invoked. But it also accepts environment variables, which I have typically used to alert PK3CMD.EXE of the the chip model.
But I will also say, that so far I've only used 5V chips, and so have never needed this flexibility.
Anyway, glad to hear you got it working now!
Thomas Henry
The -v is optional I believe so leave it off and the device file should trigger the PICkit 3 to set the proper programming voltage level. But you won't have control over the supply voltage if want PICkit 3 to power your board.
It's best to power the PIC separately anyway and PICkit 3 should sense that.
Well, it doesn't seem to be optional on my computer. If I leave it off I get a PKErr0045 error, and the flash fails. But if I include -V5, the chip flashes perfectly. This is in GCB@Syn. So, I'm going to keep using the parameter since it works.
Thomas Henry
Did You have power to the PIC separately such as power on the breadboard?
The -v option powers the PIC during programming and after. So removing that relies on external Vdd power.
I'm using the PicKit3 as a programmer only, powered only by the USB. Here's a picture of my little rig.
Having spent many hours trying to get my new pickit3 to work with pk3cmd I will resurrect the old thread to give my thoughts.
First the pickit3 seems to assume by default that you are doing in circuit programming so does not supply the power. So you have to do the -v option.
The -v option seems to require a set format #.### -v5 does not work for me.
Anyway here is my batch file that works.
cd\GCBASIC
GCBASIC /NC %1 /O:compiled.asm
C:\gputils\bin\gpasm -i -w2 compiled.asm >compiled1.err
del compiled.cod >nul
cd\Program Files (x86)\Microchip\MPLAB IDE\Programmer Utilities\PICkit3
pk3cmd -P16f1825 -V3.300 -Fc:\gcbasic\compiled.hex -m >c:\gcbasic\compiled2.err
cd\GCBASIC
notepad compiled2.err
I found my old homemade JDM programmer just does not work with the newer chips even with the Vpp lowered.
I should have pointed out that I don't use the IDE. As there wasn't one when I started using gcbasic. I use notepad then drag the file over the batch file above.