Pickit 2 Interface Guide: PC Application V2.52 Os Firmware V2.32
Pickit 2 Interface Guide: PC Application V2.52 Os Firmware V2.32
PC Application v2.52
OS Firmware v2.32
Document #:
Title: PICkit 2 Interface Guide
Subtitle: Matches Firmware Version 2.32.00, and software V2.51.00
Date: July 28, 2008
This document presents information on the design of the PICkit
Description: 2 PC application and OS firmware, and the interfaces between
the Device File, Application, and Firmware.
4.0 BOOTLOADER...............................................................................................................................................3
The Bootloader is designed to be autonomous i.e. does not require programmer firmware for operation.
The Programmer firmware, however, has its own USB stack, and does not rely on the bootloader for communication
while running. This allows the USB stack used during normal execution to be updated over USB using the
bootloader.
The programmer firmware is largely a script execution engine, with basic commands for management of scripts and
data. Data is program code, EE contents, and other information for which the programmer only acts as a conduit.
The PC application is responsible for the user interface portion of the system. Its function is to respond to user
requests by packaging data and scripts for execution by the firmware.
The device file contains all scripts and descriptions of each part supported. It is divided into 3 main sections. The
first is the family description section, which sets up some parameters common to all family members. The second is
the part description section, with an entry for each part supported. This description references scripts contained in
the third section, and defines membership in a family defined in section 1. The third section contains an indexed
listing of all scripts used by the supported parts.
4.0 Bootloader
- TBD - .
Script Buffer
768 byte indexed buffer. This buffer stores up to 32 scripts of variable sizes up to 768 bytes total.
The Script Index Table stores the beginning location and length of each script 1 through 32.
Currently scripts are limited in length to 62 bytes as that is the longest script than can be sent
via a DOWNLOAD_SCRIPT command in a 64-byte USB packet.
Mask/State bits:
Ch1 = bit 2
Ch2 = bit 3
Ch3 = bit 4
Unused Mask/State bits should be ‘0’
* If a script attempts to use data from the download buffer and it is empty, the script will abort and generate a status
error. If a script attempts to place data in the upload buffer and it is full, the script will abort and generate a status
error.
Signal levels are inverted (ie Start Bit = GND) logic level signals between GND and VDD.
A bit in the high status byte returned by the READ_STATUS command allows determination if the PICkit 2 is in
UART Mode or not.
Restrictions:
VPP will be shut off when UART mode is entered.
Scripts will not be run in UART mode if script commands are received.
PICkit 2 should NOT supply VDD in UART mode, as the Voltage Error Detection interrupt service
routines are switched off as they would interfere with the UART interrupt service routines. Thus,
supplying VDD in UART mode carries the danger of a VDD short causing damage to the PICkit 2 unit or
USB host PC.
The PICkit 2 VDD pin, however, does need to connected to the target VDD so the ICSP signals are
clamped to the proper voltage.
In UART mode, any data written to the Download Data Buffer will be transmitted on the TX pin at the specified
baud rate.
Any received data on the RX pin will be placed in the Upload Data Buffer. The PC host should poll the buffer for
data using the UPLOAD_DATA command. The Length byte in the response packet allows determination if any
data was received.
Note that the Upload Data Buffer may be overrun if the host does not keep up with the received data rate. Overflow
data will be lost.
Data Buffers should be cleared before putting the unit in UART Mode
The BUSY LED acts as an activity light (for both RX and TX).
RUN_SCRIPT and EXECUTE_SCRIPT commands will be ignored when any of StatusHigh bits 7:1 are set (i.e. a
script error exists) until the error is acknowledge and cleared by a READ_STATUS command.
Some script control bytes require arguments. Argument bytes follow the control byte directly, in the order given in
the table. All undefined byte values will be interpreted as “no operation.”
7.0 PC Application
The PC application loads the Device File into memory during startup. All families are loaded into an array of
structures, indexed by family ID. All part parameters are loaded into a linked list of structures. All scripts loaded
into an array which is indexed by script number.
NOTE: All references in following sections to “Check for connected device” include checks for voltage errors and
self-powered/unpowered target devices.
File
Import File - Loads memory arrays from hex file
Export File - Saves memory arrays into hex file
-
1 C:\TEMP\project.hex - up to 4 hex file “history” documents
-
Exit - Quits Application
Device Family
< Dynamic> - menu generated when loading the Device File.
Will have 1 entry for each device family supported.
Clicking a family entry looks for an attached device in that family.
Programmer
Read Device - Reads memory from attached device.
Write Device - Performs Chip Erase & writes GUI memory arrays to attached device.
Verify - Compares device memory with GUI memory arrays.
Erase - Performs Chip Erase.
Blank Check - Compares device memory with blank memory arrays.
-
Verify On Write - Check/Uncheck. If checked, verifies immediately after write.
Hold Device in Reset - Check/Uncheck. When checked, sets nMCLR/VPP pin = GND.
When unchecked, tri-states the pin.
Write on PICkit Button - Check/Uncheck. When checked, a Write can be initiated by
pressing the PICkti 2 button.
-
Manual Device Select - Sets the “Part Detect” property of all families to False
PICkit 2 Programmer-To-Go - Opens the Programmer-To-Go wizard
View
Single Window - The default & legacy view format
Multi-Window - Displays memories in separate windows. Enables following:
-
Show Program Memory - Toggles whether Program Memory window is displayed or not
Show EEPROM Data - Toggles whether EEPROM Data window is displayed or not
-
Associate / Memory Displays in Front
- When enabled, memory windows move with main window, and
minimize, and come to front together. Memory windows will always
display in front of Main window (as they are owned by it)
Help
PICkit 2 User’s Guide - Launches PDF file.
44-Pin Demo Board Guide - Launches PDF file
LPC Demo Board Guide - Launches PDF file.
PICkit 2 on the web - Opens www.microchip.com/pickit2 in a browser
ReadMe - Launches Readme.txt file.
About - Pops dialog with license agreement and GUI, Device File, &
firmware versions.
Config Words 1234 1234 1234 1234 Displays up to 8 config words, based on ConfigWords.
1234 1234 1234 Config1 is upper left, Config 2 is directly to the right.
Each word displayed as 4 character hex.
<> <01> Revision brackets display revision code for active device
(excludes baseline). Only visible if REVS: is added
to INI file.
1. Look for PICkit2. If not found, display an error and disable all functions. If found, check firmware version
is minimum required. If not, disable all functions except to download new firmware.
2. Check the device file version for minimum. If not valid or no device file, display error and disable all
functions.
3. Load Device File. When loading the Device File, the PC application loads the families in index order.
Each becomes a menu option under Menu “Device Family”, with the menu text being FamilyName. Any
duplicate FamilyIDs will overwrite earlier entries. The FamilyName parameter is also used to title the
status window. Ex “Midrange Device Configuration.”
4. Search for Devices. The GUI will search for devices in order of the SearchPriority family parameter. If no
device is found, the application will default to last the family setting from the INI file.
5. Initialize all memory arrays. Program memory blank value set according to device family found.
6. Set form appropriately for family and device found.
1. Check for a connected device in the currently selected Device Family. If none found, abort and update
status.
2. Read program memory into program memory array using ProgEntryScript, ProgMemRdPrepScrpt,
ProgMemRdScript, and ProgExitScript.
3. If EEMem > 0, read EE data in to EE data array using ProgEntryScript, EERdPrepScript, EERdScript, and
ProgExitScript.
4. If UserIDWords > 0, read User IDs using ProgEntryScript, UserIDRdPrepScript, UserIDRdScript, and
ProgExitScript.
5. If ConfigWords > 0, read configuration words using ProgEntryScript, ConfigRdPrepScript,
ConfigRdScript, and ProgExitScript.
6. Update status & “Source” line on GUI.
1. Check for a connected device in the currently selected Device Family. If none found, abort and update
status.
2. Check for VddErase. If Vdd below, pop warning allowing user to continue or cancel.
3. Check for date-time change on hex file, if loaded. If so, reload file.
4. If OsscalSave = ‘Y’, read OSCCAL from ProgMem-1 using ProgEntryScript, OSCCALRdScript, and
ProgExitScript.
5. Store OSCCAL into last word of program memory array.
6. If BandGapMask > 0, read BandGap config word using ProgEntryScript, ConfigRdPrepScript,
ConfigRdScript, and ProgExitScript.
7. Store BandGap bits in first word of configuration array.
8. Perform a chip erase using ProgEntryScript, ChipEraseScript, and ProgExitScript
9. Going backwards from ProgMem in the program memory array, find the last non-blank memory address.
10. Write program memory array contents up to the last address found in (4) using ProgEntryScript,
ProgMemWrPrpScrpt, ProgMemWrScript, and ProgExitScript. A 3-byte address is always sent as the first
bytes in the download buffer for each execution of the script.
11. If EEMem = 0, skip steps 11 & 12.
12. Going backwards from EEMem in the EE data array, find the last non-blank EE byte address.
13. Write EE data array contents up the address found in (11) using ProgEntryScript, EEWrPrepScript,
EEWrScript, and ProgExitScript.
14. If UserIDWords = 0, skip step 15.
15. Write User ID words using ProgEntryScript, UserIDWrPrepScript, UserIDWrScript, and ProgExitScript.
16. Verify device Code, EE, & UserIDs.
17. If verify fails, display error section & address and abort.
18. If menu Tools->Code Protect Device is selected, apply CPMask to CPConfig to enable all CP bits
19. If (ConfigWords = 0) OR (ConfigAddr < ProgMem), skip step 20.
20. Write configuration words using ProgEntryScript, ConfigWrPrepScript, ConfigWrScript, and
ProgExitScript.
21. Display “write successful”
1. Check for a connected device in the currently selected Device Family. If none found, abort and update
status.
2. Read part code memory up to VerifyStop and compare to program memory array using ProgEntryScript,
ProgMemRdPrepScrpt, ProgMemRdScript, and ProgExitScript.
3. If a mismatch is found, display error and memory address and abort.
4. If EEMem = 0, skip steps 5 & 6.
5. Read part EE data and compare to EE data array using ProgEntryScript, EERdPrepScript, EERdScript, and
ProgExitScript.
6. If a mismatch is found, display error and EE address and abort.
7. If UserIDWords = 0, skip steps 8 & 9
8. Read User IDs using and compare to User ID array using ProgEntryScript, UserIDRdPrepScript,
UserIDRdScript, and ProgExitScript
9. If a mismatch is found, display error and abort.
10. If (ConfigWords = 0) OR (Verify Device is called from Write Device) skip steps 11 & 12.
11. Read configuration words and compare to config array using ProgEntryScript, ConfigRdPrepScript,
ConfigWrScript, and ProgExitScript.
12. If a mismatch is found, display error and abort.
13. Display “verify successful”
1. Check for a connected device in the currently selected Device Family. If none found, abort and update
status.
2. Perform a chip erase using ProgEntryScript, ChipEraseScript, and ProgExitScript
3. Set all memory arrays to erased values (BlankValue for program memory array).
4. Set “Source” line to “None”
1. Check for a connected device in the currently selected Device Family. If none found, abort and update
status.
2. Read part code memory up to VerifyStop and compare to BlankValue using ProgEntryScript,
ProgMemRdPrepScrpt, ProgMemRdScript, and ProgExitScript.
3. If a mismatch is found, display “Program Memory not blank” and abort.
4. If EEMem = 0, skip steps 5 & 6.
5. Read part EE data and compare to 0xFF using ProgEntryScript, EERdPrepScript, EERdScript, and
ProgExitScript
6. If a mismatch is found, display “Program Memory not blank” and abort.
7. If UserIDWords = 0, skip steps 8 & 9
8. Read User IDs using and compare to User ID array using ProgEntryScript, UserIDRdPrepScript,
UserIDRdScript, and ProgExitScript
9. If a mismatch is found, display “User IDs not blank” and abort.
10. If (ConfigWords = 0) skip steps 11 & 12.
11. Read configuration words and compare to ConfigMasks using ProgEntryScript, ConfigRdPrepScript,
ConfigWrScript, and ProgExitScript.
12. If a mismatch is found, display “Configuration not blank” and abort.
13. Display “Device is Blank.”
Parameters:
All parameters are four characters followed by a colon. The colon is followed by a space and the value.
PCLK:< 2 - 16>
- SET_ICSP_SPEED argument for “slow” (Fast Programming unchecked)
REVS: <Y>
- When label exists, it enables display of device revision <nn> in Status Window. Delete label to disable.
LTTC: <1-256>
- trigger count setting
The device file is divided into 4 main sections. The first section gives general information about the device file
itself. The second section lists and defines device families, which contain parameters common to all parts in the
family. The third section contains parameters for each supported part, including which family a part belongs to.
The final section defines scripts that may be referred to in each part’s parameters.
NOTE: This section contains a listing of parameters and descriptions of their function. It is not intended to describe
the binary file format or order of parameters in such file. See the Source Code for file structure information.
The control bytes and arguments are stored in the low byte of each
array element.
The upper byte is used for tags:
0xAA = Control Byte (as opposed to argument byte)
0xBB = Display argument byte as hexadecimal
0x00 = Display argument byte as decimal