PIC programmer - Help Index

Disclaimer
Use this program as long as you keep in mind that this program is still far from being "professional" software !
Because this program is freeware, the entire risk of its use is with you. This also applies to the schematic diagrams presented here.

back to top


Short Description

A PIC is a small single-chip controller which can be used for many purposes.

A simple piece of hardware is required to program a PIC via the serial interface of a PC (COM1..COM4) or the parallel port (LPT1 or LPT2).

There was a simple DOS-program called "PIP-02" to do this, but that program did not work properly on my PC under windows so I wrote my own.

Programmable devices are listed on the Features page.

THIS SOFTWARE IS PUBLIC DOMAIN. THE ENTIRE RISK FOR ITS USE IS WITH YOU.

NOTE THAT THIS PROGRAMMER DOES NOT MEET MICROCHIP'S REQUIREMENTS FOR A "PRODUCTION GRADE" PROGRAMMER BECAUSE IT CANNOT VERIFY THE PIC AT DIFFERENT SUPPLY VOLTAGES.

The PIC Programmer for Windows described here is a program that lets you

I wrote this program as a replacement of the very common DOS-program "PIP-02" because that program does not work on some PCs.

Keep in mind that this program is still far from being "professional" software ! Because this program is freeware, the entire risk of its use is with you.

Check for an update on the author's homepage.

Program : PIC programmer for Windows
Revision Date: October 14, 2002
Author: Wolfgang Buescher, DL4YHF
Homepage: www.qsl.net/dl4yhf
Email: can be found on the homepage ("subject to change" !)

back to top


Features and supported devices

The program requires a simple programming interface for the serial port. For FLASH-based PICs like the 16F84, the hardware is very simple, for EPROM-based devices like the 16C61 two additional transistors are required.

Supported devices are:

WARNING ! The specification for EPROM-based PICs requires a precise timing which is hard to do under Windows. Don't let other programs run in the background when programming EPROM-based PICs (16C7xx), and use the fastest PC available. This reduces the risk that windows takes the CPU away for other tasks too long, but is no real cure.


System Requirements and Installation

You will need the following to use "WinPic":

To install the program on your PC, copy all files from the zipped archive into a new directory on your hard disk.

A few other notes about the installation can be found in the file README.TXT.

If you get some strange error messages when trying to start the program for the first time (perhaps missing DLLs), check my homepage for more information.

You will certainly need VCL40.BPL which is not included in the archive because it is too large, and it also used by many other programs. If you need this special DLL, download it from the author's homepage (see links).

back to the index


Main Window

The main window of the Pic Programmer consists of several "tabs":

Interface:
Define here what kind of interface you are using and how it is connected. Also has some features to test the programmer interface.
Code:
Shows the program memory of the PIC's "program code" as hex dump. All used words are marked green, locations where verify or programming errors occurred are marked red. Unused locations (in the hex file) are marked gray.
For special applications, you can edit the hex data after selecting "Edit...Enable Hex Editor" from the main menu. To transfer the edited hex values back into the code buffer, select "Apply edits" in the menu. This is only intended for small code patches, if you are sure what you are doing !
Data:
Hex dump of the PIC's internal data EEPROM (if present). The initial data for the data EEPROM can also be contained in a HEX file.
The hexadecimal dump can also be edited (for "special purposes") as described for the code memory.
Device,Config:
Lets you select the PIC type and change the configuration word.
Messages:
All error messages from the programmer are listed in this window in order of their appearence. The last important message will be displayed in the status line on the bottom of the main window.

back to the index


Operation

If you have ever used PIP02, you will find almost the same functions and menu structure in this programmer.

The usual operation sequence is:

  1. Start the programmer (and, if required, connect a 13V-power supply)
  2. Select the device type if necessary (dont try to load a 2kWord program into a 512 word buffer...)
  3. Load a HEX-file with "File..Load"
  4. Insert a PIC in your programmer
  5. Program the PIC with "Device..Program"

You don't have to erase the PIC before programming, the software will do that automatically.

The software will always show the success or errors of all actions. If there is an error message in the status line at the bottom of the programmer's window, change to the "message"-tab where you see a complete list of all errors (with more infos about the cause of the error, etc).

Also the configuration word and the initial DATA EEPROM will be programmed, if the HEX-file you loaded contains data in the equivalent memory ranges. For more information look into Microchip's data sheets.

After programming, reading, or successfully verifying the PIC device, the programmer (or ICSP-adapter) can be completely disconnected from the target for test code runs. You need an interface like Johan Bodin's "PIP-84 V2" which has additional hardware to disconnect all lines between the PC (parallel port) and the target device. The "disconnect control signal" is D7 on the LPT port, explained in the appendix.

back to the index


Batch Programming ("loop")

To program a whole bunch of devices with the same data, load a hex file once, then select "Tools" ... "Start Batch Programming" from WinPic's main menu. Once in this mode, the following steps are repeated over and over until you stop the batch mode (by pressing ESCAPE or via menu).

  1. The program will ask you to insert the next device to be programmed, or connect the ICSP (in-circuit serial programming) adapter to the target.
  2. When ready, press the "Enter" key on the PC keyboard or (if exists) a pushbutton on your programming adapter. Programming will start then, taking a few seconds.
  3. After programming, a green LED on the interface means "success", red LED means "error". WinPic will go back to step one.
    If LEDs show "error", it's your decision to try again or do something else (try bulk erase, etc).
Note:
A pushbutton on the programmer and the two LEDs are only available on certain programming interfaces for the parallel port.

back to the index


Command Line Arguments

You may call WinPic from a batch file, or an integrated development environment to do an automated job without any user intervention. For example, you can tell WinPic to load a program from a hexfile, write it into the target device, and terminate itself afterwards.

The following list shows all command line parameters which are accepted:

<any string not beginning with a slash>
considered a file name, and will be loaded into a buffer. If the file cannot be loaded, the evaluation of the command line is cancelled immediately; you can try to load the file "manually" then.

/p
program the buffer contents into the connected device

/q
terminates WinPic. Should be the last argument, if you want to terminate WinPic after the job is done automatically.


Note: The sequence is important, because WinPic executes these commands in the order they appear on the command line. It makes no sense to program the contents of an empty buffer, and to load a file afterwards... so the file name should be the 1st parameter on the command line, followed by the instructions what to do with the file.

The command-line driven operation can be cancelled by pressing ESCAPE. The main menu will be enabled anyway. Selecting certain menu items also cancels evaluating the command line.

Example:

winpic keyer1.hex /p /q
Loads the file KEYER1.HEX, programs it into the connected device, and terminates WinPic ("quit").

back to the index


Interface settings

The interface type must be set once after program installation, then forget about it - because WinPicPr saves the interface type (along with other settings) in an INI file. You can select the interface type from a list on the "Interface" sheet.

Depending on the interface type, you may also select COM1..COM4 or LPT1..LPT2 (see notes on the LPT port in the appendix). The default interface type is the "COM84" interface which is connected to the serial port. If you have a (simple) programmer for the parallel port which is not listed, you can add support for your own interface by adding a few lines to the SETTINGS.INI files as described in the appendix.

The programmer does a very crude "interface test" at program start to check if the interface is installed. This is done simply by setting the 'data output' and reading back the signal from the 'data input' (while the Vdd voltage turned on for a short while). If an error is reported, either the interface is not connected properly, or power turned off, or wrong port selected.

To solve interface problems, there is a simple 'Interface Test' option available where you can control all signals yourself by setting or clearing the checkmarks "Vpp", "Vdd", "Clock", "Data" (etc) and check the voltages. The actual state of the "Data In" line (from PIC to PC) is displayed as "Data In = X", where X resembles the logical state of the PIC's RB7 pin (it may be inverted by the programmer hardware).
Signals not supported by the selected programmer appear disabled in the checkmarks (for example, "Clock Enable" and "Data Enable" which are only used in Microchip's "AN589" programmer).
A crude interface test can be performed by clicking the "Initialize !" button on the Interface sheet. The result of the interface test can be viewed on the Messages sheet (the last message is displayed in the status line, clicking it will switch to the Message sheet with an error history).

back to the index


A simple 'serial' programmer for FLASH-based PICs

This  is a schematic diagram for a very simple PIC programmer on the serial port (COM1 or COM2). Check the voltage at the serial interface before deciding to build this extremely simple programmer. The 'voltage boost' via R5 may be required if the 'high-'voltage at the TXD pin is too low. If you need a circuit which also programs EPROM-based PICs, look here.

This 'very simple' programmer is only for FLASH-based PICs:

The disadvantage of this programmer is the programming voltage (which should be about 12.7V on pin 4 of a PIC16F84) taken directly from the serial interface. Some interfaces only put out about +8V maximum, and that is definitely too low for programming. You may try to connect R5 and an "auxiliary" 12V source to boost the programming voltage a litte. The "next better programmer" uses two switching transistors for the programming voltage. To program 8-pin-PICs like the 12F675 you need an adapter or an extra socket on the board.

The clamping diodes D3, D4, D5, D6 limit the voltage from the RS-232 interface to avoid latch-up of the PIC. There are some other "extra simple" circuits out there which do not use any protection for the PIC, but you should invest a few pennies/cents for these diodes. The BAT42 can be replaced by a lot of similar schottky diodes. A schottky diode is better here than the usual "1N4148" because its forward voltage is less than 500mV so we know the 'limiting' current flows through the diodes, not through the precious PIC !

back to the index


A programmer for FLASH- and EPROM-based PICs

To program EPROM-based PICs (like the 16C61/16C71), use this interface which delivers more current into 'Vpp' (programming voltage, applied to 'MCLR' = PIN 4 of most 18-pin PICs):

If a precise (regulated) 12.7 V DC power supply is available, the voltage regulator (78L12, with D7, C2..C3) is not needed.

The function of the clamping diodes (D3..D6) is explained somewhere else.

To program 8-pin-PICs like the 12F675 you need an adapter or an extra socket on the board.

See also: PIC programmers for the parallel port

back to the index


Selecting the Device and setting the configuration word

The tab sheet "Device, Config" is used to select a PIC device and modify the configuration word. It is very recommended to embed the configuration word in the HEX file (so you don't have to set the proper config word yourself), but you may want to check or modify the configuration word yourself after loading the HEX file.

Depending on which PIC type is selected, only a few of the following option bits exist in the configuration word. The checkboxes for non-existing option bits are automagically disabled ;-)

Oscillator
Most PICs have the option "LP" (low-power), "XT" (crystal or ceramic resonator), "HS" (high-speed crystal), or "RC" (resistor+capacitor, with the capacitor sometimes integrated in the PIC).
Code Protection
Protects the program to be read out. If code-protected, the program cannot be verified. Leave this bit off, for heaven's sake ! Some PICs support code-protection for different code memory areas. This PIC programmer does not (if code protection is enabled, ALL CP bits are treated the same way).
Power-Up timer
Consult Microchips datasheet. They call it "PWRTEN". If the checkmark is set, the power-up timer is enabled (no matter if the bit is inverted in the config word or not.
Watchdog Enable.
If the checkmark is set, the watchdog is enabled and you must feed it in your program periodically.
Data Protection
Rarely used. Allows read-out protection for the (EEPROM-) data memory.
Low Voltage Programming
A feature supported by some newer PICs, but not by this programmer. Would allow in-circuit programming without a 13-volt programming pulse, for the expense of a port bit.
Brown-out Reset
If this checkmark is set, the PIC will go into the RESET state if the supply voltage drops below a certain voltage. See datasheet.
MCLR Enable
Some PICs like the 16F628 allow using the MCLR pin as a normal I/O port. If this checkmark is SET, the MCLR pin is used as a "Master CLeaR" input like in older PICs.
In-Circuit Debug
Rarely used, look into the PIC16F87x datasheet if you need this.
Code Write Enable
An interesting feature of the PIC16F87x family. Allows the CODE MEMORY(!) to be reprogrammed by the PIC application itself, so you can write a custom 'bootloader' or use the program memory for data storage etc.

If a PIC is not directly supported by the programmer, set the PIC type  ("Part") to "unknown". Then all checkmarks for the options in the configuration word are disabled, but the Config Word can still be edited as a hexadecimal value. See 'unsupported PICs' for more information.

Device properties:

Shows the size of the program memory and the data EEPROM memory. If the PIC type is set to "unknown", the device properties can be edited.

back to the index


Appendix

PIC programmers for the parallel port

Using a simple PIC programmer at the parallel port can cause headaches under certain Windows versions. Sometimes the printer driver (or whatever?) accesses the port though WinPic tries to occupy the port itself. This somehow depends on the signal used to read back the data from the PIC. Especially the PAPER OUT signal seems to attact Window's attention .. and should be avoided for this reason. I did not check if removing all printer drivers can help, if you know more please let me know.

WARNING ! Because Windows fools around with the parallel port, and we don't know the state of the parallel port before starting the programmer, first connect the programmer with the PC, then turn the PC on, start the programmer, and insert the PIC into the socket (or connect the ICSP cable) shortly before programming !

However, it may be possible to use a few  -in the days of DOS widely used-  interfaces. Supported (but not all tested) are the following interfaces, along with their major differences:

PIC programmers for the parallel port
Interface type Data PC->PIC Clock PC->PIC Data PIC->PC Vpp Control Vdd Control Remarks
FLASH PIC programmer
V1 (by SM6LKM, 09/2002)
D2,
not inverted
D3,
not inverted
ACK,
inverted
D4, inverted
(L=Vpp on)
D0, not inv.
(H= Vdd on)
ICSP adapter with
D7 = ICSP connect
PIP84
(by SM6LKM)
D2,
not inverted
D3,
not inverted
PAPER,inverted D4, inverted
(L=Vpp on)
D0, inverted
(L= Vdd on)
D1=green LED
D7=ICSP disconnect
PIP84
(alternative)
D2,
not inverted
D3,
not inverted
ACK,inverted D4,inverted D0,inverted D1=green LED
D7=ICSP disconnect
Tait,
7406, 4066
D0,
inverted
D1,
inverted
ACK,
inverted
D3,
not(?) inv
D2,
not(?) inv
7406=inverter
4066=switches
Tait,
7407, 4066
D0,
not inverted
D1,
not inverted
ACK,
not inverted
D3,
not(?) inv.
D2,
not(?) inv
7407=non-
inverting driver
Tait,
7406, PNP
D0,
inverted
D1,
inverted
ACK,
inverted
D3,
inverted
D2,
inverted
7406=inverter,
+ PNP-transistor
Tait,
7407, PNP
D0,
not inverted
D1,
not inverted
ACK,
not inverted
D3,
inverted
D2,
inverted
David Tait's
"classic" design
Microchip
"AN 589"
D0 D1 ACK D3 none
(always on)
D2=data tristate,
D5=clock tristate,
D4=MCLR

Signals at the 25-pin "LPT" connector (SUB-D at the PC)
Pin Nr Signal token name
in interface
definition file
Direction
Description
(usual function)
1 /STROBE str PC->printer 'Byte clock'
2 D0 D0 PC->printer Centronics Data
3 D1 D1 PC->printer Centronics Data
4...8 ...  ... PC->printer Centronics Data
9 D7 D7 PC->printer Centronics Data
10 /ACK ack printer->PC Acknowledge
11 BUSY bsy printer->PC Busy or Error
12 PAPER pap printer->PC high=printer ran out of paper
13 SELECTED sld printer->PC high=printer is on-line
14 /ALF alf PC->printer automatic line feed
15 /ERROR err printer->PC out of paper, error, offline
16 /INIT ini PC->printer resets the printer
17 /PRINTER SEL psl PC->printer low = select printer
18..25 GROUND - connect ALL LINES to ground

Not listed in the above table: ICSP Connect/Disonnect  ... based on an idea by Johan Bodin:
Centronics D7 (inverted) is used as an additional control line for in-circuit programming. This signal is used to *totally* disconnect the programmer from the target system (using relay(s) and/or CMOS analog switches or whatever). This eliminates the need to plug/unplug the programming connector for code test runs. Some target systems may have very hi-z circuits connected to the programming pins, RB6/RB7 (GP0/GP1).
D7 = LOW means "Programmer shall be connected to target"
D7 = HIGH means "Programmer shall be disconnected from target" (you'll find D7 HIGH after booting the PC in many cases)
After switching this signal to LOW (=connect programmer to target), the software waits at least 200 milliseconds until the first attempt to switch the PIC into programming mode. This should be enough for electromagnetic relays.

back to the index


Adapting WinPic for other (simple) programming interfaces

If your (simple) programmer hardware for the parallel port is not listed in the 'interface' tab sheet, you can create your own by adding a few lines to the SETTINGS.INI file which is located in the directory where you installed WinPic. Here's what to do:

[ProgrammerControlLines]

with the following entries ... some of them optional, only a few are mandatory, marked with "m"=mandatory:

DataIn (m)
serial data line from PIC to PC
OkButton
signal from programming adapter to PC for an optional "OK"-button.
VppOnOff (m)
control line to turn the programming voltage on(H) and off(L). From PC to PIC.
VddOnOff
control line to turn the supply voltage on(H) and off(L). From PC to PIC.
Connect
control line to connect(H) or disconnect(L) the target. From PC to programming interface. Usually "!D7".
ClockOut (m)
serial clock output from PC to PIC.
DataOut (m)
serial data output from PC to PIC.
ClkEnable
Tristate buffer control for the serial clock output. As far as I know, the only interface which uses this is the original Microchip "AN589" programmer. "H" level means output enabled (from PC to PIC), "L" means output disabled (high impedance)
OutEnable
Tristate buffer control for the data output. As far as I know, the only interface which uses this is the original Microchip "AN589" programmer. "H" level means output enabled (from PC to PIC), "L" means output disabled (high impedance)
RedLed
Optional output from the PC to a red LED on the programmer, signalling "error state" after programming.
GreenLed
Optional output from the PC to a green LED on the programmer, signalling "success" after programming.

The function token in the definition file is followed by a "=" character, and a symbolic definition for the control signal which is used. This can be any of the centronics data lines, inverted (LOW-active) or not inverted (HIGH-active). "Active" must be seen from the target's point of view. If -for example- there is an inverter between the serial data output on centronics D0 and the PIC's "RB7" pin, the definition line must be

DataOut=!D0

which means
"The serial data output is connected to D0, inverted"  (the '!' character to invert something is "C"-style)

These names can be used for control lines on the centronics port ("LPT1" or "LPT2"). Non-inverted always means active-HIGH level on the PC's output, no matter what the centronics printer specification says.

D0, D1, ... D7 
centronics data, not inverted. Can be used as OUTPUTS from PC to target.
!D0, !D1, ... !D7
centronics data, inverted. Can be used as OUTPUTS from PC to target.
pap,  !pap
centronics "paper out", normal (H=active) or inverted (L=active). Can be used as INPUT from target to PC.
ack,  !ack
centronics "acknowledge", normal (H=active) or inverted (L=active). Can be used as INPUT from target to PC.
str, alf, psl, ini
Other control signals OUTPUTS from PC to target: strobe, automatic line feed, select printer, initialize printer(reset).
bsy, sld, err
Other INPUTS from target to PC: busy, selected, error

(Other "control signal tokens" are listed in the LPT connector table, or in the  SampleInterface.INI file. If you have the source code of WinPic, look for "PicHw_TokenToInOutFunc()" to find out which tokens are really implemented so far ;-)

To continue the procedure to install a customized programming interface...

If everything is ok, check the proper function of the control lines with the interface test option. Keep your interface definition file in WinPic's directory, because this file will be loaded whenever you start the program again (the definitions are NOT copied into the SETTINGS.INI file. Only the name of "your" interface definition file is saved in the settings !)

back to the index


Adapter for PIC12F629/675

The PIC12F629 / PIC12F675 is a low-cost PIC with 8 pins and flash memory, the F675 has four 10-bit A/D converters.

If you already made a (non-ICSP-) programmer for the 16F84 / 16F628 family, you need an adapter socket from 18-pin (16F84) to 8-pin (12F629/675). The pinout of the new 12F629/675 is:

(pinout PIC16F675)      (my ugly adapter)

The following table helps to make an adapter from 18-pin PICs to 8-pin PICs:

PIC pins for serial programming of 18- and 8-pin PICs
Pin Function Pin Nr & Name
PIC16F628 (18 pins)
Pin Nr & Name
PIC12F675 (8 pins)
Remarks
Power supply

14
"Vdd"

1
"Vdd"

+ 5 V

Ground

5
"Vss" :-(

8
"Vss" :-(

don't say
"Vss" :-)

Prog Voltage

4
MCLR/Vpp

4
GP3/MCLR/Vpp

12 V pulse

CLOCK

12
RB6

6
GP1/CIN-/VREF


DATA

13
RB7

7
GP0/CIN+

:


Help - my PIC is not supported !

If you don't find the PIC you want to program in the combo list on the tab sheet "Device,Config", you should try this:

If you still have no success after this, try to READ or VERIFY an already programmed PIC. Maybe the ICSP commands (In-Circuit Serial Programming) are totally different, or your PIC cannot be programmed or read via ICSP at all - bad luck ! The maximum code memory size is 8192 WORDs.

At the moment, only PICs with 14-bit code words have been tested. From Murphy's law, PICs with 12- or 16-bit code words cannot be programmed..

In this case, search the web for "DL4YHF PIC Programmer" and you will hopefully find the site where an update can be downloaded.

back to the index


Literature, PIC Links

Just a few links, not frequently updated. Some of them may already be "dead"...

Disclaimer: The links presented here are under the sole control, copyright and responsibility of the authors of their pages. I am unable to take any responsibility for the content of web-sites that you reach through these hyperlinks.
This note has been added because of a court decision where the author of a website was made responsible for the contents of "foreign" websites which could be reached via a link from his own page !!!

http://www.microchip.com
Here you can download all data sheets, application notes and their excellent windows-based development system. A definitive MUST if you want to write own PIC programs. Because microchip keep moving their files around, you must find the way to MPLAB yourself.

http://home.swipnet.se/~w-41522/pic/pic.html
Johan Bodin's site where the PIP84 programmer is described, along with a simple DOS program to drive it. A PCB layout for his in-circuit programmer is also available.

http://www.thepicarchive.cwc.net/dtpa/links.html
This is a mirror site of David Tait's excellent PIC pages. Though David has stopped updating this site most links are still active.

http://www.ccc.nottingham.ac.uk/~cczsteve/pic84.html
Steve Marchant's in-system programmer may possibly be supported by WinPic one fine day .. but no-one asked me to do so yet.

http://www.clinet.fi/~newmedia/pic/
Sam Enström has an other guide to get started with PICs. The "extra simple serial programmer" is described there, along with the schematics.

http://www.qsl.net/dl4yhf/
The author's HAM RADIO homepage where you'll find the latest release of this program, and also the VCL40.BPL library if you need.


last modified: October 14, 2002

--... ...-- ...-.-