Menu

Using PicKit 3 Command Line Utilities With GCB

2016-05-19
2016-05-20
  • William Roth

    William Roth - 2016-05-19

    Using Pickit3 Command Line with Great Cow Basic

    Microchip ended support for the venerable Pickit2 several years ago. While the Pickit2 can still be used to program many current and legacy devices. It cannot be used to program many of Microchip's latest 8-bit microcontrollers. This includes the very nice and feature-rich 16F188xx and the 16F16xx series of chips.

    In order to program these newer 8-bit PIC microcontrollers with Great Cow Basic and SynWwrite IDE there are seveal options. Here I will discuss using the Pickit3 with the IPE and PK3 command line utilities.

    There are three current command line utilities available for Pickit3. These are provided with Microchip MPLAB X and are NOT included with Great Cow Basic. To get these utilitites, MPLAB X IPE must be installed on your PC or Laptop. I suggest downloading the latest version of MPLAB X, and then running the setup, but only selecting to install the IPE (Integrated Programming Environment).

    This will install all the necessary files as well a separate install of Java SE. Java is required for these utilities to work. MPLABX 3.30 currenly installs JAVA JRE 8.65

    Note:
    Microchip no longer supports Windows XP with MPLAB X. It is recommended to use Win 7 or above. I could not get MPLAB X to install using XP Pro with 3G memory and an AMD processor. However, with a some fiddling, I did get it to intstall with XP Pro using an all Intel P4 system (Dell). Still not recommeded nor supported. If you have problems with MPLAB X and Win XP, I cannot help you.

    The three command-line utilites are:

    1. ipecmd.jar

    2. ipecmd.exe ( basically identical to above)

    3. pk3cmd.exe (Not the same as PK3cmd.exe provided with MPLAB 8.x !)

    These utilities will be located in the "C:\Program Files\Microchip\MPLABX\v3.30\mplab_ipe" folder if the default install location is selected.

    These all do basically the same thing but require different command line options in the GCB "flashPic.bat" file. All require Java in order to work.

    Here are the steps to get these woking with the IDE "Flash Hex".

    1. Download and Install the latest version of Great Cow Basic
    2. Download and Install The latest Version of MPLAB X "IPE" (Now 3.30)
    3. Open the Great Cow BasiC IDE
    4. Select Tools > External Tools > Edit PIC programmer batch file
    5. Pickit2 is used by default in flashpic.bat, so scroll down to the line that starts with "PicKit2/Pk2cmd.exe .... and remark it out with REM

    To Use IPECMD.jar:
    Scroll down to the line that starts with "REM java -jar and change it to read:

       REM java -jar "C:\Program Files\Microchip\MPLABX\v3.30\mplab_ipe  \ipecmd.jar" -TPPK3 -P%2 -F%1 -M
    

    To Use IPECMD.exe
    Add another line to read:

    REM "C:\Program Files\Microchip\MPLABX\v3.30\mplab_ipe\ipecmd.jar" -TPPK3 -P%2 -F%1 -M
    

    To use PK3CMD.exe
    Add another line to read:

       REM "C:\Program Files\Microchip\MPLABX\v3.30\mplab_ipe\pk3cmd.exe" -P%2 -F%1 -M
    

    Finally .. For these three variants, unremark the one you want to use and remark out the other two then save and close the FlashPic.bat file.

    =========================================================

    Command Line Options: IPECMD.xx
    The command line options for ipecmd.jar and ipecmd.exe are exactly the same and can be found in:

    C:\Program Files\Microchip\MPLABX\v3.30\docs\Readme for IPECMD.htm

    Note 1:
    Missing in this help file is information related to setting the VDD Voltage when the Pickit 3 is used to power the microcontroller using the W option. To set a specific voltage, add the desired voltage after -W with no space.
    Example: -W3.3

    Note 2:
    Setting the voltage to 5.0 will produce an error. The Pickit 3 is powered by the USB VBus and due to voltage drop will never be able to supply 5V given a 5V VBUS. Try 4.25 V instead.

    Command Line Options: PK3CMD.exe

    The command line options for PK3CMD.exe can be found in.

    C:\Program Files\Microchip\MPLABX\v3.30\docs\Readme for PK3CMD.htm

    Note3: The command line options are different from those used for IPECMD. Read the support files !


    Below is the FlashPic.bat file that I now use. Other programing options have been removed to eliminate clutter. THIS FILE WILL ONLY WORK WITH PICKIT 3!
    Code:


    @echo off
    echo *** flashPIC.bat ***
    echo.
    REM  Version 0.95.006 - Added chip checking for PicKit2
    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 ********************************************** 
    REM *** This File will only work with PicKit3! ***
    REM *** ******************************************
    
    REM  *** Call PicKit3 command-line programming software:
    REM  *** Note, that MPLAB X and the Java Runtime Environment (jre) must be installed!
    
    java -jar "C:\Program Files\Microchip\MPLABX\v3.30\mplab_ipe\ipecmd.jar" -TPPK3 -P%2 -M -F%1
    REM "C:\Program Files\Microchip\MPLABX\v3.30\mplab_ipe\ipecmd.exe" -TPPK3 -P%2 -M -W3.3 -F%1
    REM "C:\Program Files\Microchip\MPLABX\v3.30\mplab_ipe\pk3cmd.exe" -P%2 -V4.3 -M -L -F%1
    
    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
    

    William

     

    Last edit: William Roth 2016-05-19
  • Chuck Hellebuyck

    Nice summary but I have to question the statement about PICkit 2:
    "It cannot be used to program many of Microchip's latest 8-bit microcontrollers. This includes the very nice and feature-rich 16F188xx and the 16F16xx series of chips".

    Have you tried updating the pk2 device file?
    I have a link to the device file editor and the details on my PICkit 2 page:
    http://www.elproducts.com/build-your-own-pickit-2.html

    I'll have to try it on a those chips. I think I have them. I was able to get it to work on the 16F178x parts. I doubt the programming algorithm is different. Just need the programming spec details.

     
  • William Roth

    William Roth - 2016-05-20

    Chuck,

    There is no device file available that supports 16F16xx of 16F188xx chips. The algorithms are quite different. There is no "family" match for these chips, and no existing PK2 "script" that supports 16F chips with 5 config words.

    You will not only need the device file editor, you will also need a script editor and you will need to write some new scripts specific to these chips.

    In regards to the 16F178x chips ... that device file may have worked, with command line - but the chip ID mask was incorrect as it was placed in an incompatible "family". This caused the PK2 and PK3 GUIs to fail with 16F1788/1789 as the Chip ID was incorrectly detected.

    There was no real support 16F1789 but the command line for PK2 doesn't care much about IDs may program a chip with the wrong settings/ ID.

    I added better support for 167F1788/89 in several device file versions. A corrected device file for 16F1788/89 may still avilable in the "files" area. However, I sent Evan quite a few variations of the device file and am not really sure what we are shipping with the current release version of GCB. My guess is that it has incorrect Device IDs for 16F1788/1789 (Confirmed)

    If you open up the device file in the editor and see where the device ID is either 3020 or 3021 for 16F178x, then it will not correctly support 16F1788/1789 . Likewise if the ID is correct 302B/302A but the ID mask is incorrect ( Family 14 =-0x00003FE0) then the PK2 and PK3 GUIs cannot detect the chip.

    The correct ID mask for 1788/1789 is 0x00003FFF (16383) so the 1788/1789 could be moved to family 18 and should work correctly with both command line and GUIs.

    Attached is an "Unofficial" PK2 Device file that adds support for quite a few more chips and corrects the GUI issues with 16F1788/1789 as it uses the correct ID mask for these chips. This is the file that I personally use with PK2, It is a combination of the David S file as modified by the folks at Pic Pascal, as modified/hacked by some Russian programmers, as corrected/modified by me. I offer no guarantees, but it works well on all the PIC chips that I have, excluding 16F16xx and 16F188xx. I have no intention of attempting to add support for these chips since the PK3 IPECMD works perfectly on these.

    While the PK2 is undoubtedly a superior product to PK3 and I understand wanting hold on to it (as I held on to Windows XP) as long as possible, the simple facts are:

    1. Microchip no longer supports PK2 and there will be no official updates
    2. Pickit 2 does not support many newer chips
    3. Pickit 3 with IPECMD supports all current 8-Bit PIC chips

    William

     

    Last edit: William Roth 2016-05-20

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.