USBProg User's Guide 2 February 2008 This document describes how to set up and operate a Embed Inc USBProg PIC Programmer. The purpose of the USBProg programmer is to "program" data into Microchip PIC microcontrollers (PIC is a registered trademark of Microchip Technology Inc). Setup the Software Go to the web page http://www.embedinc.com/picprg/sw.htm and follow the directions for downloading and installing the software. Install the software before connecting the programmer to the computer. Setup the Hardware To set up the programmer hardware in the normal way, do the following: 1) Connect the USB. Use the cable that was supplied with the programmer or a compatible cable. Plug one end into the USB connector at the left side of the programmer. Plug the other end into a USB socket on your computer. There is only one way to connect the cable, so if it fits, it's right. The STATUS LED should light dimly. 2) Connect to the target circuit. The programming signals are available two different ways. Both programming connections are at the right side of the USBProg: 1) The RJ-12 connector labeled "PrgOut" has the same pinout as the RJ-12 connector of a Microchip ICD-2. Any means of connecting an ICD-2 via its RJ-12 connector can also be used with the USBProg. 2) Six pin locking header labeled "P8". The function of each pin is labeled directly on the circuit board. This interface has two ground pins instead of the single ground pin used by the ICD2 interface. The extra ground pin facilitates making cables that eliminate the PGD to PGC crosstalk problem by separating these two signals with a ground wire. P8 is a standard header with square pins .025 inches on a side and with a pin pitch of .1 inches. For more information about PGD to PGC crosstalk and other circuit design considerations for in-circuit PIC programming, see http://www.embedinc.com/picprg/icsp.htm. Verify the Setup The directions in this section assume that the software and hardware have been set up as described in the previous sections. The STATUS LED should be dimly lit. To verify the hardware and software setup, make sure you are running a command shell and enter: pic_prog at the command prompt. This should report the firmware type as USBProg, its version number, the name of the organization that created it, and the unique name of the particular USBProg. If the USBProg is connected to a target system with one of the supported PIC types that contains an internal ID word, then the target PIC model and its silicon revision will be shown. Otherwise a message is shown indicating that the device ID of the target chip could not be read. If more than one USBProg is connected to the USB, then one of them will be arbitrarily chosen unless its name is given explicitly. For the PIC_PROG program, this is done with the -N command line option. The factory default name for each USBProg is "USBProgXXXX", where XXXX is the unit serial number expressed with 4 digits. The serial number of each unit is at the lower right corner of the circuit board. For example, to explicitly check USBProg with serial number 123, use the command: pic_prog -n USBProg0123 Note that the name is case-sensitive. The name can be changed with the PIC_CTRL command using its -SETNAME option. See the PIC_CTRL documentation file for details. Normal Operation Several programs are included in the standard software for using the USBProg. Each program has a separate documentation file in the DOC directory within the software installation directory. See the DOC files for details on how to use these programs. Briefly, the programs are: PIC_PROG Program or verify the target PIC from the data in a HEX file, such as produced by MPLAB. This program also has other capabilities and various options. See the documentation file for details. PIC_READ Read the data from the target PIC into a HEX file. PIC_CTRL Low level control of the programming lines. Can also rename a programmer. PICPRG_LIST List all compatible PIC programmers that can be enumerated by the host computer, which includes USBProgs connected via the USB. TEST_PICPRG This is a low level test program not intended for end users. It is not fully documented. This program can be useful when developing your own software, or you may be asked to run it in an attempt to diagnose a problem. Type HELP at the ": " prompt to get a brief list of commands. Status Light The status light is the green LED labeled "Status" at the right edge of the unit. It indicates 5 different states: Unlit No power is applied to the unit. The target system may be connected or disconnected in this state. Dimly but solidly lit Idle state. The unit is powered on, but otherwise inactive. The target system may be connected or disconnected in this state. Flashing at 4 Herz, brightness is low. The host is communicating with the unit, but the target system is not powered from the USBProg. Do not connect or disconnect the target system in this state. Flashing at 2 Herz, brightness is medium. The target system is powered up. Communication with the target may be in progress, but the target is not being written to (no permanent target state changes are being made). This is the normal display during verification or data readback. Do not connect or disconnect the target system in this state. Flashing at 1 Herz, brightness is high. The target chip is being actively written to. This is the normal display during a "programming" operation. Do not connect or disconnect the target system in this state. The status diplays have been deliberately chosen so that obvious flashing indicates the target system should not be connected to or disconnected from the USBProg. Doing so while the status light is flashing may permanently damage the target system. The target system may be connected or disconnected when the status light is solid, including completely off. RS-232 Operation The USBProg can optionally communicate to the host computer via RS-232. The serial communications signals are available at connector P5, labeled "Serial", at the top of the board. When looking at the board so that the writing can be read normally, pin 1 is on the left and pin 4 on the right. Pin 1 is also marked with a square pad whereas the remaining pins have round pads. The pins of P5 are: 1 - 5V power out. 2 - Serial data in. 3 - Ground. 4 - Serial data out. The USBProg signals are 0-5 volts and inverted from RS-232. A adapter is required to connect the serial data signals to a standard PC COM port (RS-232). A suitable adapter is the Embed Inc RSLink (http://www.embedinc.com/products/ser). The 5V power out line from the USBProg is only intended to power a RS-232 adapter. No more than 15mA should be drawn from this power output. The serial communication parameters are 115.2Kbaud, 8 data bits, no parity bit, 1 stop bit. The USBProg may be connected to a host (or different host) computer via USB and RS-232 simultaneously. Operation is undefined if more than one program is run simultaneously that attempts to communicate with the USBProg. However it is permissible to use either interface at any time as long as they are used sequentially. One program must complete before another program may be run on the other interface. Optional power When using only the serial communication interface of the USBProg, it may be powered from the USB or powered separately. To power the USBProg without a USB connection, use connector P2 at the left side of the board. The pins of this connector are labeled "5V" for 5 volts and "Gr" for ground. The power requirements are 4.5 to 5.2 volts and up to 500mA. The USBProg MUST NOT be connected to a USB and external power via P2 simultaneously. Doing so may damage the USBProg, the external power supply, and the host computer connected to the USB. Software Updates New software is made available from time to time. Go to the web page http://www.embedinc.com/picprg/sw.htm to check on the latest released version. Firmware Updates New firmware is made available from time to time. Go to the web page http://www.embedinc.com/picprg/sw.htm to check on the latest released version. The PIC_PROG program can be used to determine the current firmware version loaded into the USBProg. USBProg firmware is stored in files named EUSBxx.HEX in the SRC/PICPRG directory within the software installation directory, where XX is the firmware version number. To change to a new firmware version, perform the following steps: 1) Disconnect power from the USBProg. The Status LED must be completely off. 2) Create a cable that connects to the 5 pin locking header labeled "P4 PrgCtrl" at the top edge of the programmer. The pins of the programming connector are numbered 1-5 starting with 1 at the left pin. Pin 1 is also identified with a square pad, which can be see on the bottom of the board. The pinout of the PCTRL connector is: 1 - Vpp 2 - Vdd 3 - GND 4 - PGD 5 - PGC Connect the other end of the cable to a PIC programmer, such as another USBProg, a Microchip ICD-2, etc. The other programmer must be able to program the PIC 18F2550. 3) Program and verify the new PPRGxx.HEX file into the USBProg using the second programmer. 4) Disconnect the USBProg from the second programmer. 5) Power up the USBProg. 6) Make sure the USBProg is the only programmer connected to the system and run the command: pic_ctrl -setname USBProgXXXX where XXXX is the serial number of the USBProg. The serial number is indicated in the lower right corner of the circuit board. This step restores the programmer name to its original factory value, which guarantees it is globally unique. If you have set the name of the programmer to something else, use that name instead of USBProgXXXX. The program may exit with error "cyclic redundancy check" or something similar. Ignore this error when using the -SETNAME command line option. 7) Run the PIC_PROG program and verify that the firmware version and programmer name are as expected.