PIC programmer - Help Index

Disclaimer
THIS SOFTWARE IS CONSIDERED 'FREEWARE'. THIS SOFTWARE IS PROVIDED AS IS AND WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED.

In other words, THE ENTIRE RISK FOR THE USE OF THIS SOFTWARE IS WITH YOU.
Permission is granted to use, modify, or redistribute this software so long as it is not sold or exploited for profit.
Use this program as long as you keep in mind that this program is no professional software !
Because this program is freeware, the entire risk of its use is with you. As usual, neither the author nor contributors will be liable for anything. This also applies to the schematic diagrams presented in this document, and in "the software" itself.
A missing copyright note in these documents does not indicate "no copyright" for names of products or companies mentioned here.
If you like to read more of this legal stuff, look into the README file in WinPic's main directory.

contents


Short Description

PICs are single-chip microcontrollers which can be used for many purposes. WinPic can program some of these devices, using a simple piece of hardware connected to the serial port (COM1..COM4) or the parallel port (LPT1 or LPT2) of a PC. There once 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. Thanks to my contributors, WinPic now supports a large variety of PICs with different programming algorithms. Programmable devices are listed on the Features page.

Note that most programming adapters supported by WinPic do not meet Microchip's requirements for a "production grade" programmer. If you think you need a production grade programmer (which can verify the PIC at different voltages), look here.

If you're interested in developing PIC firmware, buy an interface like the PicKit 2 or 3 (not a clone). PicKit 3 is not the most reliable development tool, but it can also be used as an in-circuit debugger, at least for more recent PIC devices.
Thus, except for trivial 'ad-hoc' PIC- and dsPIC-projects there is no need for programs like WinPic anymore. The WinPic author gave up developing PIC firmware, since there are more powerful devices like Cortex-M supported by a wealth of free development systems.
Consider this: For the price of ONE "PicKit 3", you could buy FOUR Cortex-M4 development boards, with onboard debugger. Or two Raspberry Pi's, but that's a different breed...
and even Cortex-M0 devices are available in breadboard-friendly 28 pin DIL package, and (sorry having to say this) any ARM/Cortex development toolchain is more mature than the C compilers by Microchip (which, in the "free" editions, produce anything but good code).
Ok, back to the subject:     WinPic lets you ...

WinPic will not let you ...

Keep in mind that this program is still far from being "professional" software ! Last not least because this program is freeware, the entire risk of its use is with you - read the disclaimer if you haven't yet.

Check for an update on the author's homepage.
Note: Meanwhile there are other programs called "WinPic" on the web. If you look for an update, search the net for "WinPic" AND "DL4YHF" to find this one !

Program : WinPic - a PIC programmer for Windows
Revision Date: 2006-11-02 (YYYY-MM-DD)
Author: Wolfgang Buescher (DL4YHF) and contributors, see "About"-box
Sourcecode: available on the author's homepage
Homepage: see links at the end of this document
Email: can be found on the homepage (subject to change / spambots keep off !)

Contents


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 (AT LEAST...) :

WARNING ! The specification for EPROM-based PICs requires a precise timing which is hard to realize 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.

If you don't find "your" PIC in the list of supported devices, you may add support for it as described here .

Contents


System Requirements and Installation

You will need the following to use "WinPic":

If you have an interface which is not directly supported : the programmer can be customized for other programming adapters via INI-file.

Since WinPic is now distributed with an automatic installer, you simply select where it shall be installed (after reading and agreeing to the disclaimer). After installation, you should see the following files :

?\WinPic\devices\*.dev ....... subdirectory with device definitions borrowed from MPLAB
?\WinPic\html\*.* ............ WinPic's online manual in HTML format
?\WinPic\interfaces\*.ini .... custom interface definitions ("programmers")
?\WinPic\translations\*.txt... translations of the WinPic GUI into other languages
?\WinPic\WinPic.exe .......... the executable
?\WinPic\smport.sys,smport.vxd, porttalk.sys ..... the optional port access drivers(*)
?\WinPic\devices.ini ........ file telling WinPic how to program some new PIC devices
?\WinPic\readme.txt ......... disclaimer, short info, revision history
(*) earlier versions of WinPic did not work with the port drivers. Click here for details. 

A few other notes about the installation and translations can be found in the file README.TXT. In case of trouble, please read the FAQ list.

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

If you use WinPic to program PIC18F or dsPICs, read this chapter in the FAQ's - it shows you how to tweak WinPic for maximum speed for "simple" PIC programmers (works best with the PortTalk driver). To use PortTalk without an administrator account under Windows XP, you can install PortTalk permanently on your system as explained here.

Contents


Main Window

The main window of the Pic Programmer consists of several tabsheets:


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.
ID locations (now called "Configuration Memory"):
Shows the contents of the user ID locations and the PIC Device ID word, and -optionally- the contents of some other cells in the configuration memory area. You can edit these locations manually, but it's better to embed ID information in a hex file. Unlike the code memory, the ID locations can always be read out even if the PIC is code protected.
Options:
On this tab sheet, you can modify the behaviour of the programmer (but not the PIC itself).
Interface:
Define here what kind of interface you are using and how it is connected. Also has some features to test the programmer interface.
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.

Contents


The "Tool" Window

Screenshot of tool windowIf you use WinPic for programming with an integrated development system (like MPLAB), and frequently program your PIC for testing purposes, use the small tool window. It remains open on top of any window, even if it doesn't have the focus, and even if WinPic's main window is minimized. You can reload the new file and program it with a single mouseclick on the "Reload & Program"-button. The name is the last file you selected for loading from WinPic's file menu. The filename is shown below the button.

To open the Tool window, select "Tools"..."Show Tool Window" from the main window.  To switch back to the main window, use the ">>" button in the lower right corner.

During programming, a progress indicator and the current status is also displayed in the tool window. If programming is finished successfully, the tool window turns green, in case of errors it turns red.

Contents


Operation

This is the usual operation sequence in interactive mode (for command-line mode, see another chapter):

  1. Start the programmer (and, if required, connect a 13V-power supply)
  2. Select the device type if necessary (because different PICs require different programming algorithms)
  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.

You can terminate the programming loop anytime by pressing the ESCAPE key - this may save a few seconds if you discover you have not inserted a PIC in the socket.

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.

Contents


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.

Contents


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.
If the command line contains a /p command ("program)", this file 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.
If the command line contains a /r command ("read"), this is the name of the produced hex file.
If there is only a filename specified in the command line, but none of the following "switches", the specified file will be loaded into WinPic's buffer automatically but not programmed into the device.
/p
program the buffer contents into the connected device
/e
erase chip. Not necessary to use this command together with the 'program' option because 'p' will automatically erase if necessary.
/r
read the contents of the device and dump them into the specified HEX file

/v
Verify. Compares the contents of the device with the specified HEX file. Can be used as an "extra" verification together with the /p command, but this is usually not required because the programming algorithms for most PICs include verifying.

/q
terminates WinPic. Should be the last argument, if you want to terminate WinPic after the job is done automatically. Without this command, you must close WinPic manually, even when running in command-line mode.
/q=5
also terminates WinPic, but waits for 5 seconds before quitting so you will have the chance to look at any output in the message window.
/nodelay
Usually, when command-line driven operation is active, the program waits for a few seconds until "the action starts". This can rescue a chip, because it allows you to terminate the erase-programming operation if you have started the wrong batchfile by mistake, etc.
With the /nodelay option, there will be no pause before the execution of the command line starts.
/overwrite
With this option, WinPic won't ask before overwriting an already existing disk file. Use it together with the /r command if necessary.
/device=XXXX
Selects a new device type (to override the device used in the last WinPic session). Example: /device=PIC16F628 . No space characters are allowed in here !
/config_word=XXXX
Overrides the configuration word from any loaded hex file. The parameter XXXX is as a four-digit hexadecimal value.


Note: The sequence is no longer important (this was different in older releases of WinPic, where the file name had to be specified before the "/p"-command etc).

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.

Some commandline examples:

winpic keyer1.hex /p /q
Loads the file KEYER1.HEX, programs it into the connected device, and terminates WinPic ("quit").
winpic /nodelay c:\pic\my_src\keyer1.hex /p /q
Almost the same, with full path to the hexfile, and a bit faster without the 3-second-pause during which the ESCAPE key is polled.
winpic /overwrite /r "readout.hex" /q
Reads the contents, dumps the program to the file "readout.hex" (and overwrites the old file without asking). Terminates automatically.

Contents


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.

Note: For interface on the LPT port, WinPic must use one of the port access drivers (SMPORT or PortTalk). Since November 2006, it does not need such a port driver for the serial port. In fact, WinPic may work with USB<->RS-232 converters, too.

The programmer does a 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).

Beware that different PICs require different programming- and supply voltages these days (not as in the 'old days' where Vpp = 12 V and Vdd = 5 V was always safe..).
If WinPic has access to Microchip's dev-file for the selected PIC, it will know which voltages can be used, but with none of the 'simple' programming adapters it can set the required voltages itself ! (This is what justifies the higher price of the 'commercial' adapters by Microchip: They have programmable supplies for Vpp and Vdd).
So it is your duty to set the correct programming- and supply voltage for your PIC. The circuit diagram of the author's 'Serial Programmer V2 shows how this can be achieved by connecting lower-voltage Zener diodes parallel to the always present 12- and 5-V diodes for Vpp and Vdd, respectively.

A note on serial interfaces:
USB->RS-232 adapters only work when the option "no direct port access, only use Windows API" is set (on WinPic's "Options" tab, on the "I/O Port Access Driver" tab). Some cheap USB<->RS232 adapters didn't seem to work with WinPic because they don't handle some handshake signals correctly :-(
It's not necessary to enter the I/O port address of the serial port's control registers anymore, since it doesn't make sense these days to access the serial port chip's control registers directly, because the 'serial port' is in fact an USB <-> RS-232 port adapter. Thus, in 99.9 % of all cases, WinPic cannot access the control registers directly, and is doomed to control the modem control registers through a windows API function. Only if the PC has a "real" serial port but the I/O-address is not the standard value, you can double-click into the edit field "Addr", and enter the I/O address in hexadecimal form. Caution: Entering the wrong value here can seriously damage your PC, so make sure you enter the right address for the right COM port number (you can find out your COM-port's I/O-address in the system control panel).

Some of the interfaces which are supported by WinPic are:

To tweak WinPic for maximum speed, you may try to optimize the following parameters on the Interface tab (the default settings are reasonably slow and reliable):

These additional delays can be used for "slow" interfaces, especially when the PortTalk driver is used instead of SMPORT. More details on that here.
For a sluggish USB <-> serial port interface, the 'extra delay' values had to be set to at least 1000 microseconds, for reasons explained here.

Contents


Simple interfaces for the serial port (which do not require a programmed PIC)


Introduction: Why 'simple interfaces' for the serial port often don't work with USB adapters

In the good old days, PCs had 'real', easy-to-use serial port interfaces, which were ideal to drive simple 'bit-banging' PIC programmers like the ones listed further below in this chapter (like 'COM84' which seems to be the grandfather of anything developed later, like "JDM", "JDM 2", "K8084", "Ludipipo", etc etc etc).
All these interfaces do not use the serial port's data lines the way they were intended to be used. Instead, because the PIC's serial programming protocols are anything but compatible with the serial data frames of an RS-232, or "UART", aka "COM port". To program a PIC, the serial port's handshake lines are (ab-)used as clock and data lines, and (in most cases) to control the PIC's programming and supply voltage. This used to work perfectly well when PCs were equipped with 'real' serial ports, based on the 8250 UART, and later 16550 UART chip, with directly accessable ("modem"-)control registers. The direct register access allowed controlling the output lines with a very precise timing: The 'wanted' state appeared at the DTR- and RTS-outputs a few microseconds (or even faster) after the software modified the right control bit in the UART's modem control register.
Unfortunately, with a USB <-> serial port adapter this is not possible anymore, because we are doomed to the USB transfer type used by the adapter's driver. For example, a USB 1.1 (*) adapter will have a latency of 1 millisecond for each transfer, thus for a single data bit bit-banged over the handshake lines, would require at least 3 (!) milliseconds:
(*) USB 1.1 is still common for cheap serial port adapters; don't let their "USB2-" or "USB3-compatibility" fool you !
The manufacturer of these interfaces often don't care about the latency of modem control signals like DTR and RTS, because for their original use, it didn't matter too much if the DTR or RTS output switched a few hundred microseconds sooner or later.

If the PC (WinPic) tried to set the output lines faster than the USB driver can 'send' (which in WinPic happens via EscapeCommFunction), clock bits would get lost, or (at least) the electric signals would appear at DTR and RTS with a messed-up timing.
With older windows versions (and older USB 'COM port' drivers), the EscapeCommFunction (windows API function) seemed to block until the data had really been sent to the hardware interface. When using a 'Prolific USB-to-Serial Comm Port' adapter under Windows 8.1, none of the calls to "EscapeCommFunction" seemed to block, even when trying to toggle DTR and RTS ten thousand times per second (which is impossible, due to the limitations of the USB hardware). In other word, WinPic wasn't slowed down sufficiently by the driver, and some of the bit-banging operations must have failed even though the driver did not indicate a problem (which WinPic would have shown on its 'Messages'-tab).
This is the reason why many of the old 'very simple' interfaces (COM84, Ludipipo and Co) refused to work properly without a 'real' COM-port, even if the programming voltages were sufficient.
Programming was only possible (with WinPic, Windows 8.1 and the already mentioned 'Prolific' adapter) when setting the
'Extra Delay' (on WinPic's Interface tab) to 1000 microseconds (same for "before reading the data line" and "lengthening for clock pulses"). Programming a PIC16F628 was possible this way, but of course it was incredibly slow.

'Clock feedback' option for DL4YHF's modified PIC programmer for the serial port (anno 2015)

For a larger (ds)PIC, a different solution was found to avoid waiting for longer than necessarily. With a "better" (faster) USB <-> serial port adapter, WinPic should only wait as long as is it takes for the CLOCK signal to arrive at the PIC. Principle of this 'clock feedback' (or 'clock read-back') :
After changing the state of the 'CLOCK'-line (RTS from PC to PIC), the program waits until the 'CLOCK'-signal has reached the wanted state. To achieve this, WinPic waits until the DSR line (='feedback' from the PIC programmer to the PC) reaches the same logic level as the RTS line. This happens on both POSITIVE and NEGATIVE transitions of the CLOCK signal. So the only modification of an existing "COM84"-compatible interface was adding a 'feedback'-line for the CLOCK signal, from the PIC's 'CLOCK' signal to serial port's DSR input.


9-pole "D-sub" connector, male, "DTE" connector side

Pin Number on
9-pin DTE (PC)
Signal Name
on DTE (PC)
Direction from the DTE's
(PC's) point of view
For 'COM84' interface, used as

1

DCD

input

2

RxD

input

3

TxD

output

Vpp control (+12 V)

4

DTR

output

data from PC to PIC

5

GND

signal ground

6

DSR

input

clock feedback from PIC to PC

7

RTS

output

clock from PC to PIC

8

CTS

input

data from PIC to PC

9

RI

input

The circuit diagram below shows DL4YHF's modification (anno 2015) for a 'simple' programmer. The new 'clock feedback' line is shown in blue colour. Other PIC programming software (like PICpgm) will most likely be compatible with this interface - it will simply ignore the state of the 'clock feedback' signal on DSR, and rely on user-adjustable delays instead.
To use the adapter with the 'clock feedback' option in WinPic, select 'DL4YHF serial programmer' instead of 'COM84' on the 'Interface' tab.

For dsPIC and PIC18, add the components for 'PGD / PGC filtering' shown in red colour. These lowpass filters shall reduce crosstalk between PGD (data) and PGC (clock). They must be located as close to the PIC as possible; for in-circuit programming, locate them on the target board (not on the programming interface).

A 'strong' Vpp source as shown in the circuit above is only required for very old chips, with EPROM (not FLASH) memory. If the programming adapter only needs to support Flash-based PICs, the Vpp line only needs to source fractions of a milliampere. To reduce the risk of accidentally ruining your target board (when not 13-Volt-tolerant circuitry is connected to the alternate function of MCLR/Vpp), add a series resistor before the MCLR input (close to the PIC).

To program PICs which require lower programming- or supply-voltage, use additional Zener diodes to keep all voltages in the range specified in your PIC's datasheet. Beware, some devices are killed by Vdd = 5 V, others are killed by Vpp = 12 V !

With the 'clock feedback', the programmer will always use the maximum speed, as permitted by the USB adapter, and it's not neccessary to fiddle around with the extra delays on WinPic's Interface tab any longer.
The speed can be tested by clocking out a long stream of 1,0,1,0,... (there's a button to start this test on the 'Interface' tab). Shown below is the test result using a 'Prolific' USB adapter. Each USB transaction obviously consumes one millisecond, and because each bit clock cycle requires two transactions (one to set CLOCK=high and shift out DATA, one to set CLOCK=low again), it takes two milliseconds per "serial bit", and since a single word in the PIC's code memory requires approximately 28 cycles (for the PIC16F628, includes sending the 'increment address' command), programming an entire PIC with this adapter consumes about 125 seconds (!). "That's not a bug, but a feature" (of this USB 1.1 adapter).


DATA and CLOCK waveform, measured when using an unlabelled
'Prolific USB-to-Serial Comm Port' adapter. 1 ms per half bit cycle,
resulting in a total time to read or program a PIC16F628 of 125 seconds !

For comparison, on a PC with a 'real' serial port (Thinkpad X61s with docking station), with the same PIC, same configuraton, programming or reading an entire PIC16F628 finished in less than 5 seconds.


'DL4YHF Serial Programmer V2' for the serial port (anno 2016)

When studying the datasheet for a PIC16F1782/PIC16F1783, a nice feature of this chip was found:
By means of a register called 'APFCON' (Alternate Port Function Control Register), the pins
  with ICSP data (PGD, for PIC16F1783 on RB7) could also be used as RXD on the PIC side,
  and ICSP clock (PGC, for PIC16F1783 on RB6) could also be used as TXD on the PIC side.
Thus the ICSP interface shown below can also connect the target (PIC) to a terminal program (like the
terminal integrated in WinPic).
This is helpful for program development, if you don't want to invest in a real debugger like Microchip's PicKit3.
The schematics below show a modified programmer hardware, this time intended as an 'ICSP' (in-circuit serial programmer).


DL4YHF Serial Programmer V2, can be used to connect the
target to a terminal program (besides being an ICSP adapter).

PC side of 'DL4YHF Serial Programmer V2' Connect 6-pin ICSP adapter to ...
Pin Number on
9-pin DTE (PC)
Signal Name
on DTE (PC)
Direction Usage ICSP pin Pin on SPDIP-28
 PIC16F1782/3
Pin on SPDIP-28
 dsPIC30F3013

1

DCD

? → PC

-

2

RxD

PIC → PC

terminal: PIC-TXD

3

TxD

PIC → PC

ICSP: write data,
terminal: PIC-RXD

4

DTR

PIC → PC

Vpp+MCLR control

1

1 (Vpp/MCLR/RE3)
max 9 Volt !
1 (Vpp/MCLR/RE3)
max 13 Volt !

5

GND

PIC ↔ PC

signal ground

3

8, 19 (connect both!) 8, 19, 27 (connect all,
    including AVss)

6

DSR

PIC → PC

ICSP: clock feedback

5
PGC/TXD

27 (ICSPCLK/RB6) 18 (PGC/.../RF2)

7

RTS

PIC ← PC

ICSP: clock

8

CTS

PIC → PC

ICSP: read data

4
PGD/RXD

28 (ICSPDAT/RB7) 17 (PGD/.../RF3)

9

RI

? → PC

-

PIC supply voltage

2

20 (Vdd)
"L": max 3.6 V !
13, 20, 28 (connect all,
incl. AVdd, max 5 V)


To use this interface, set the interface type to 'DL4YHF Serial Programmer V2' in WinPic.
After programming / reading / verifying the PIC, WinPic will turn off the high programing voltage. But this may keep the PIC in the RESET state (because MCLR is pulled low), unless the /MCLR function (low-active RESET input) is disabled via configuration word.
If you prefer to keep the /MCLR input enabled (which is advisable in some cases), add a manually operated switch or jumper, in series with the /MCLR input to your target. Open the switch to prevent the /MCLR input being pulled low by the programmer. This lets the target 'run' while WinPic operates as a simple terminal emulator (with RXD and TXD only, no handshake).

To program PICs which require lower programming- and/or supply voltage, use additional Zener diodes to keep all voltages in the range specified in your PIC's datasheet. Beware, some devices are killed by Vdd = 5 V, others are killed by Vpp = 12 V !

Due to the weak 'Vpp' source, this interface cannot be used to program ancient EPROM-based PICs, which doesn't hurt much (it doesn't make sense to use an IN-CIRCUIT programming adapter for such chips anyway).

A simple 'serial' programmer for FLASH-based PICs

The following schematic diagram is for a simple "COM84-compatible" PIC programmer on the serial port (COM1 or COM2). You should build a more advanced programmer ! 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 for the PIC to enter programming mode. If you need a circuit which also programs EPROM-based PICs, or want something with a more reliable 'programming'-voltage, look here. If you need a circuit which works without extra supply (under all conditions), try the JDM programmer type 2 (TWO! ... search the net for "JDM PIC-programmer 2" to find the schematics; it is supported by WinPic too, and -unlike other "simple's"- the JDM 2 works for PIC18Fxxx and even dsPICs.)

This 'very simple' programmer is only for certain FLASH-based PICs. Again, I strongly recommend not to use it, however ... :

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. A schottky diode (e.g. BAT46, 1N5817, PMEG2005) must be used, not an ordinary silicon diode (like the ancient 1N4148) because its forward voltage is less than 500mV so we know the 'limiting' current flows through the diodes, not through the precious PIC !

When tested with a 16F877 (and an adapter socket), this interface failed, while programming an old-fashioned 16F84 worked. This is why I strongly recommend to use the programmer described in the next chapter, or an even better one...

Some notes on "AllPic2"

Some years ago, a programmer called "AllPic2" (or "AllPic02") appeared in several magazines. It is compatible to "COM84", and to the two interfaces shown in this document, but very often you will find it has :

Contents


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). The circuit shown below was slightly modified in 2015-12, so if you build one from scratch, consider using this circuit instead (which contains the PGD & PGC filters mentioned further below).

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.
To program some 28-pin PICs like the 16F876 you need another adapter, and yet another adapter for the 28-pin dsPIC family.

If you experience problems with dsPIC30Fxxxx, PIC18Fxxxx, or other unexplainable problems which seem to be related to the length of the interface cable, read this important note on PGD & PGC filtering (avoid coupling between clock- and data line).

See also: PIC programmers for the parallel port

Contents


Selecting the Device and setting the configuration bits

The tab sheet "Device, Config" is used to select a PIC device and modify the configuration word. It is highly 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.

In the combo box labelled "Part:", you select the PIC device which shall be programmed.

Note:
The upper part of this list contains devices which are build-in ("hardcoded") into WinPic, the second part after the "unknown" PIC dummy are user-defined devices which are loaded from the file DEVICES.INI. Some devices may appear twice: The first from the "built-in" definition, the second uses the programming parameters loaded from DEVICES.INI which you can modify yourself to add support for "new" devices. Device definitions in DEVICES.INI always override the definitions in the internal (built-in) list.
See also: Adding support for chips which are not supported by WinPic yet.

The contents of the table of configuration bits depend on the selected device type, and on the device definition file. Only for "old" devices (PIC16F family), WinPic contains built-in configuration bit definitions. For newer chips, especially the PIC18F and dsPIC30F family, the configuration bit info should be read from one of Microchip's device definition files (*.dev). WinPic expects the DEV-files in a certain directory - see this textfile for more information. The DEV-files are Microchip's own property, and due to the MPLAB terms of use I cannot distribute them with WinPic. But you will have them on your harddisk after installing MPLAB !

Below are some bits (and bit groups) in the configuration memory which WinPic can handle even if there is no dev-file for the currently selected device:

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.
Config Word #2
Only used for a few new devices like the PIC16F88. There is no 'decoder' for the bits in the second config word. Please refer to the PIC's data sheet. There is an extra bitmask for the 2nd config word in the DEVICES.INI file ("Cfgmask2_used_bits") which is essential for verification, because only a few bits are really implemented and may be checked when verifying the 2nd config word.

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. Note: Other areas in the chip's configuration memory may be shown on the Configuration Memory tab (for example the chip's ID locations, backup oscillator calibration value, etc)

Device properties:

Shows the size of the program memory and the data EEPROM memory. If the PIC type is set to "unknown", some device properties like code- and data memory size can be edited. Instead of using the "unknown PIC" option, it's better to add support for your new PIC device as explained in the appendix.

Contents


Configuration memory and ID Locations

A user may store identification information (ID) in a number of programmable cells, often four or seven bits per location. These locations are mapped to addresses 0x2000 to 0x2003 (that's where you may find them in a HEX file; applies to "14-bit core"; for other cores the addresses are totally different). In contrast to the code memory, the ID locations can be read unscrambled even if the PIC is protected.

In MPASM (the assembler from microchip), there is the __idlocs command (with two underscores) to set these bits, but only the lower 4 bits in every location. The __idlocs command bundles 4 * 4 bits in a single 32-bit value, presumably because older PICs only had 4 usable bits per ID location. But the 12F675 for example has seven bits per location !

With WinPic, you can read / modify / write the ID locations (all bits). If ID location data are contained in a HEX file, they will be loaded and displayed also. WinPic does not display the data in MPASM's 4*4-bit-format, it uses a table where all bits are displayed in binary form. You can edit the contents of the grid table. After doing so, click the "Apply edits" button under the table. Clicking this  button copies the table contents into an internal buffer, but does not program them into the PIC immediately - the ID locations will be programmed together with the other programmable parts in a PIC.

The "Device ID word" can be used to identify a chip after reading the PIC. This 14-bit word is mapped to address 0x2006, but not all PICs seem to have it (a test with an old 16F84 always returned 0x3FFF as device ID). The lower 4 or 5 bits may contain the PIC's revision number in some devices. WinPic tries to decode the device ID word and shows the result on the "ID locations" tab. If there is a conflict between the selected PIC device and the readout ID word, the Device ID display turns red. If WinPic cannot find a match for the device ID of the new chip, you may add a new entry to the device database as explained here (don't forget to set the parameter "DeviceIdValue" to the new chip's device ID).

Configuration Memory (display table)

When new PIC devices with new cells in the configuration memory area (0x2000..0x203F) turned up, the appearance of the Configuration Memory tab was modified. Now, after setting the checkmark "show ALL locations", the entire memory area may be displayed, whether it's implemented in the PIC or not.

The "Config Memory" tab may also show the contents of some other special function registers which did not fit on the "Configuration Bits" tab. For example, you will find the PIC10F20x's Backup OSCCAL Value in this table.

Because it is entirely unknown how many (and which) cells will be used in the configuration memory in future devices, WinPic's device table now contains information of all really "implemented" cells. More about this in the chapter about the file  DEVICES.INI, which describes how to add support for future devices.

Contents


Options

On the "Options" tab you can modify the behaviour of the PIC programmer (software), how WinPic accesses the parallel or serial port, and modify some other parameters which may need 'tweaking' for various reasons. Here are just some of them:

Use BULK erase (to unprotect)
Check this options if there may be code-protected PIC devices in your junkbox. What Microchip once called 'bulk erase' is now called 'chip erase' for some newer devices. In fact, it 'erases everything' including protected code memory, and the protection bits itself. Without this flag, WinPic may use a byte-by-byte erase function for all memory cells (this method was once used to reduce FLASH memory wear, but it is incompatible with the specified programming algorithm for most newer devices). For this reason, leave this option CHECKED as it was by default.
Verify at different supply voltages
Only possible with special programming interfaces as described in the appendix unter 'production grade programmers'. If this option is disabled, your interface is not a production grade programmer - don't worry about this as a hobbyist !
Raise Vdd 50 microseconds before raising MCLR to Vpp level
Certain devices like the PIC16F818 are not happy with the way older PICs were treated, where the MCLR signal was quickly raised from 0 Volts to the 'programming' voltage (typically 13 Volts) while the supply voltage ("Vdd") was still zero. If this option is checked, the supply voltage (Vdd) is turned on roughly 50 microseconds before the MCLR signal is raised from 0 to 13 Volts. Because this is impossible with the simple "COM84"-style interfaces (which has no separate Vdd and Vpp control lines), an ugly trick is used to achieve a similar effect: Turn Vpp+Vdd on, wait a few hundred milliseconds to charge the "Vdd"(!) capacitor, turn off again, wait 50 microseconds, and turn Vpp+Vdd on again. This will cause problems for certain devices where the RESET pin can be disabled via configuration word.
A PIC16F88 could only be programmed with this option.
A PIC12F675 (with INTRC and no /MCLR) could only be programmed without this option.
A PIC16F628 could be programmed with and without this option.
If you experience problems with re-programming an already programmed PIC (with internal osc and w/o external reset), turn this option off (clear the checkmark) and try again - maybe it helps.


Port Access Control

By default, WinPic does NOT try to access the registers of the serial port directly, because all of the port drivers mentioned below caused problems with other programs (noteably Microsoft's "Windows Defender" didn't like the SMPORT driver). So try to use WinPic without these drivers, if possible. Only if your PIC-programmer is connected to the parallel port (LPT), you must use one of the drivers below, because the Windows API doesn't have the necessary functions for that port. This worked ok under most Windows versions so far, but it may be painfully slow when programming larger PICs because every single port access required a driver call (from ring 3 to ring 0, if that means anything to you..). Now there is the option to select how WinPic accesses the I/O-ports. This is on the 'Options' tab:

Contents

The 'Terminal' tab

WinPic contains a very basic terminal emulator. It communicates with the target as 'plain text' via the serial port's "RXD" and "TXD" line.
Characters typed into the transmit window (upper part) are sent via the PC's TXD-output, characters received at the PC's RXD-input are printed into the receive window (lower part).

Since the handshake lines are usually occupied for in-circuit programming, there is no flow control.
The serial data format is always 8-N-1 (eight data bits, no parity, one stop bit), the serial baudrate can be entered on the Interface tab.

One of the 'simple' ICSP adapters which can als be used to connect the terminal to the target is the 'DL4YHF Serial Programmer V2'. It uses a nice feature of some PICs (e.g. PIC16F1782/3), which can reconfigure the ICSP-clock and -data' line as UART I/O lines. So after programming a new firmware, you can leave this ICSP adapter in place, and use it for "printf-style" debugging. Of course, this is not a replacement for a real in-circuit debugger.


Appendix

PIC programmers for the parallel port

See also (more common these days) : PIC programmers for the serial port

Using a simple PIC programmer at the parallel port can cause headaches under certain Windows versions. First of all, you must select one of the port access drivers mentioned above, because the Windows API (application interface) doesn't have suitable functions for the parallel port. Even worse: 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 sometimes 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 ! If you get an error message from WinPic saying "Windows fooled around with the parallel port bits", read this .

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.
If your programmer shall support dsPIC and PIC18F too, read this note on PGC- and PGD filtering.
(2004-01-26: Modified the TAIT-programmer settings after I found some more schematics on the web)

PIC programmers for the parallel port
Interface type Data PC->PIC Clock PC->PIC Data PIC->PC Vpp Control Vdd Control Remarks
PIC FLASH programmer
V1 (SM6LKM, 2002-10-01)
D2,
not inverted
D3,
not inverted
ACK,
inverted
D4, inverted
(L=Vpp on)
D0, not inv.
(H= Vdd on)
ICSP adapter with
D7 = ICSP disconn(*)
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,
inverted
D2,
inverted
7406=inverter
4066=switches
Tait,
7407, 4066
D0,
not inverted
D1,
not inverted
ACK,
not inverted
D3,
not inverted
D2,
not inverted
7407=non-
inverting driver
Tait,
7406, PNP
D0,
inverted
D1,
inverted
ACK,
inverted
D3,
not inverted
D2,
not 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=Pull MCLR down
Signals on the PC's 25-pin "LPT" connector (SUB-D)
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/Disconnect  ... 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, so HIGH=DISCONNECT is the safer state)
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.

Parallel port trouble

Sometimes (especially under Windows XP) you may get a sloppy error message from WinPic telling you that "Windows fooled around with the parallel port". The reason for this may be a scanner driver, printer driver, or the plug-and-play hardware detection which permanently polls the port for new devices. Of course, this will spoil the operation of a PIC programmer connected to the parallel port !

The problem could sometimes be fixed by adding (or modifying) the following key in the windows registry :

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Parport\Parameters]

"DisableWarmPoll"=dword:00000001

Search the web for "Jan's Parallel Port FAQ"; the site contains details about this registry hack.
Caution: Only modify the registry if you know what you're doing ;-)

Contents


Adapting WinPic for other (simple) programming interfaces

If your (simple) programmer for the parallel or serial port is not listed on the 'interface' tab, here's what to do (besides the option to write a plugin for it) :

[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. Example for a simple interface on the serial port:
DataIn=cts
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. Example for a simple interface:
VppOnOff=txd
VddOnOff
control line to turn the supply voltage on(H) and off(L). From PC to PIC.
PullMclrDown
control line to pull the MCLR pin down to ground. As far as I know, only Microchip's "AN589"-programmer uses this (with PullMclrDown=D4)
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. Example for a simple interface on the serial port:
ClockOut=rts
DataOut (m)
Definies the interface signal which is used to send serial data output from PC to PIC. Example for a simple interface on the serial port:
DataOut=dtr
DataOutWhileReading
Defines the logic state (not a control signal) of the data output line while reading. For most interfaces, the data output must be set to a logic "1" by the programmer, so the PIC can pull the serial output low (because most interfaces use an NPN-transistor or open collector output stage, and a pullup resistor connected to Vdd). For interfaces with a tristate output, the level of the serial ouput line while reading doesn't matter (use "OutEnable" to define the control line for the tristate driver in that case). Example for a simple interface on the serial port:
DataOutWhileReading=1
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). Example for a simple interface:
ClkEnable=nc
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 (signals which are inverted by the PC hardware are automatically inverted by software !).

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
nc
not connected. Use this token for all unused/unsupported functions, like "RedLed=nc" .  All unused functions appear disabled on the "Interface Test" tab.

For an interface on the serial port, these control lines are available (may be used if you have an interface with an inverting RS-232 level converter like the MAX232). If you use the original "COM84" programmer, you don't have to write your own interface definition !

txd, !txd
Transmit Data (here: abused as simple control line). For COM84, "txd" is used as programming voltage (non-inverted)
dtr, !dtr
Data Terminal Ready. For COM84, "dtr" is used as serial data output from PC to PIC (non-inverted)
rts, !rts
Ready To Send. For COM84, "rts" is the serial clock output from PC to PIC.
cts, !cts
Clear To Send. For COM84, "cts" is the serial data input (from PIC to PC).

Other "control signal tokens" are listed in the LPT connector table, or in the  SampleInterfaceXXX.INI files. Every macro definition can control up to 4 output lines, like:
SelVddHigh=D0+D1+!D2+!D3
which will set both D0+D1 high and D2+D3 low when the supply voltage shall generator shall be configured for "high supply voltage (see notes on simple production-grade programmers).

If you have the source code of WinPic, look for "PicHw_TokenToInOutFunc()" to find out which tokens are implemented so far ;-)

To continue the installation of 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 !)

Driving other hardware through a Programmer-Plugin (DLL)

Since 2008, it is possible to add support for other interfaces in the form of a plugin-DLL. To use such a DLL, it must be copied into the folder "interface_dlls" (in the WinPic installation archive). Then, set the interface type to "Custom, on any port, from plugin-DLL" on WinPic's INTERFACE tab. Next, click the "Select"-button on that page. A file selector dialog will open up, asking you for the name of the interface-DLL in the folder mentioned above.

If you have developed your own PIC programming interface -possibly with a USB interface- and want to add support for it using WinPic, you can write your own interface DLL with a free C compiler like DevC++ V 4.9.9.2 . You will find the complete sourcecode for such a DLL on the author's website, along with the necessary documentation.

The "interface_dlls" folder will be empty after installation by default (except for a small readme file) to avoid bloating the WinPic installation archive. But a list of DLL-plugins for other PIC-programmers will be available on the WinPic website, as soon as such DLLs exist ;-)

Back to the table of contents


"Production grade" programmers

Microchip's PIC requirements for a "production grade" programmer specifications require to verify the PIC at different voltages. If you think you really need this, you can use WinPic to drive a simple programming adapter which does this (it's a bit crude, however, see below).

The basic principle is this: WinPic controls the supply voltages with a few digital output lines of the parallel port. Your hardware can use this to switch a couple of trimpots which adjust the supply voltage. I have never built such a programmer myself (because I never missed such a thing) but if you'd like to, look into the file SimpleProductionGradeProgrammer.ini (it's in the zipped archive where you found WinPic.exe).  Here is an example for the interface definition file of a "simple" production-grade programmer:

[ProgrammerControlLines]
DataIn=!ack
OkButton=!sld
VppOnOff=!D4
VddOnOff=D0
SelVddLow=D5+!D6+!D7
SelVddNorm=!D5+D6+!D7
SelVddHigh=!D5+!D6+D7
Connect=nc
ClockOut=D3
DataOut=D2

The definitions of the three "SelVdd"-macros control the supply voltage (here: D5 and D6 of the parallel port). WinPic executes the "SelVpp"- macros BEFORE switching on the supply voltage, with a pause of at least 100 milliseconds (enough to charge/discharge a capacitor with a few uF's). After settling of the supply voltage, it is actually turned on with the "VddOnOff" macro (here: D0 will be SET to turn the PIC's supply voltage on). Some PICs require a fast rise time of the supply voltage, so use a switching transistor controlled by the "VppOnOff" macro (D4 in this example), and place the buffering capacitor "BEFORE" the Vpp switch !

Suggestion: Use the "Vdd selection" lines to drive two or three NPN transistors, with trimpots in the collectors, and emitters connected to ground. The trimpots can be part of a voltage divider connected to an simple regulator. No need for an analogue switch !

To verify a PIC program at different voltages, you must turn on the option "Verify at different supply voltages" on the options tab. If the adapter does not support this (because the SelVdd-macro definitions are missing in the interface definition file, or are defined as "nc"=not connected), this option will be grayed and WinPic will ignore it (it will only do a single verification run then, instead of three runs with Vdd=Vdd_norm, Vdd=Vdd_min, Vdd=Vdd_max in this order). If one of the three possible voltage are not supported by the programmer, define the voltage control lines as "not connected" like this, which lets WinPic skip that verify-step:

SelVddHigh=nc

Note:  This three-voltage-verification is not very smart. It takes about three times longer than verifying at a single voltage, and IMHO is not required for hobbyist purposes - and that's what we are talking about. It may be an issue if you plan to run a PIC very close (or even below) its specified operating voltage. In this case, it makes sense to verify it at that low voltage.

Contents


Adapter for PIC16F87x (28 pin SDIP)

This adapter was used to program a PIC16F876A with 28-pin standard DIP, using a programmer which was originally built for the 16F84/16F628 :

Adapter for PIC16F876 (and similar) with a 18-pin PIC programmer
Pin Function Pin Nr & Name
PIC16F628 (SDIP 18)
Pin Nr & Name
PIC16F876 (SDIP 28)
Remarks
Power supply

14
"Vdd"

20
"Vdd"

+ 5 V

Ground

5
"Vss"

8 and 19
"Vss"

connect all
"ground" pins !

Prog Voltage

4
MCLR/Vpp

1
MCLR/Vpp

12 V pulse

CLOCK

12
RB6

27
RB6 / PGC


DATA

13
RB7

28
RB7 / PGD

 


Note: The 16F8xx may be affected by capacitive coupling from PGD to PCD (data to clock), so in case of trouble add two capacitors as described here.


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 once-famous 16F84 or 16F628 family, you need an adapter socket from 18-pin (16F84,16F628) to 8-pin (12F629/675). The pinout for the 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 (except PIC10F)
Pin Function Pin Nr & Name
PIC16F628 (18 pins)
Pin Nr & Name
PIC12F675 (8 pins)
Pin Nr on SM6LKM's
PIC FLASH board V1
Remarks
Power supply

14
"Vdd"

1
"Vdd"

2
Vdd

+ 5 V

Ground

5
"Vss" :-(

8
"Vss" :-(

3
GND :-))

don't say
"Vss" ;-)

Prog Voltage

4
MCLR/Vpp

4
GP3/MCLR/Vpp

1
Vpp

12 V pulse

CLOCK

12
RB6

6
GP1/CIN-/VREF

5
RB6


DATA

13
RB7

7
GP0/CIN+

4
RB7

 


Note: Though it looks ugly, this adapter may be (or may be not) used to program some 14- or 20-pin chips, too. For example, the ICSP pins of the PIC16F690 are at the same physical pins as for the PIC12F675, even though the pin numbers are not the same. But beware, some PICs have a "low voltage programming input" which needs to be tied to low level while programming.


Adapter for PIC10F20x (6-pin SOT-23 or 8-pin PDIP)

To program a PIC10F20x with your old "simple" programmer, you need yet another adapter, because the PIC10F20x 8-pin packages are not pin-compatible with the PIC12F6xx shown in the previous chapter ! (remember this before the smoke comes out). The following table may help to build an adaptor for PIC10F200/202/204 /206 :

Adapter from PIC16F628 (18-pin) to PIC10F20x (8-pin)
Pin Function Pin Nr & Name
PIC16F628 (SDIP 18)
Pin Nr & Name
PIC10F20x (PDIP 8)
Pin Nr & Name
PIC10F20x (SOT-23, 6 pin)
Power supply

14
"Vdd"

2
"Vdd"

5
"Vdd"

Ground

5
"Vss"

7
"Vss"

2
"Vss"

Prog Voltage

4
MCLR/Vpp

8
GP3/MCLR/Vpp

6
GP3 / MCLR / Vpp

CLOCK

12
RB6

4
GP1/ ICSPCLK

3
GP1 / ICSPCLK

DATA

13
RB7

5
GP0 / ICSPDAT

 1
GP0 / ICSPDAT

Handling of OSCCAL and Backup OSCCAL Value (by WinPic, for PIC10F20x)

The PIC10F20x only runs with an internal 4-MHz-RC-oscillator which must be "calibrated" by moving a certain value into the OSCCAL registers in the very first instruction of your application. The calibration value is the operand of a MOVLW instruction at code memory address 0x0FF (or 0x1FF, depending on the code memory size). There is a "backup" OSCCAL value (at address 0x104 or 0x204). WinPic reads both these locations before erasing the chip, and restore them automatically if the read values are valid. If both calib values in the PIC10F20x are invalid, WinPic will use the values from its code- and config memory buffers. If the buffered values are also invalid (because they don't contain a MOVLW opcode), WinPic will refuse to program the chip (unless the option "Don't care for OSCCAL value" is set.
So, if you get the following error message ...

PIC10F: Abort programming (nothing erased). No valid OSCCAL value found !
Enter a valid BACKUP OSCCAL VALUE (like 0x0CF4) on the Config Register Tab, then try again !

... then switch to WinPic's "Config Memory" tab, where you can enter the OSCCAL value of your chip. Then hit "apply changes" and try programming again. To avoid losing the individual OSCCAL value of your precious sample, read it out and scratch the hexadecimal number into the PIC's plastic package - so you can always find it when you need it ... ;-)


Adapter for PIC16F636 / PIC16F684 / PIC16F688 (14 pin DIP) / PIC16F690 (20 pin DIP)

This adapter was used to program a PIC16F684 with 14-pin SDIP case, using a programmer which was originally built for the 16F84/16F628. I tested it with a JDM-style interface and it worked ok. For details, consult Microchip's specification DS41204 .  The same socket was used for PIC16F631/677/685/687/689/690 (20-pin DIP package), because the pins used for serial programming are at the same physical locations though their pin numbers are different.

Adapter for PIC16F684 (14-pin) and PIC16F690 (20-pin)
Pin Function Pin Nr & Name
PIC16F628, etc
(18 pins)

Pin Nr & Name
PIC16F684, etc
(14 pins)

Pin Nr & Name
PIC16F690, etc
(20 pins)

Pin Nr on SM6LKM's
PIC FLASH board V1
Remarks
Power supply

14
Vdd

1
Vdd

1
Vdd

2
Vdd

+ 5 V

Ground

5
"Vss" :-(

14
"Vss" :-(

20
Vss

3
GND :-))


Prog Voltage

4
MCLR/Vpp

4
RA3 / MCLR / Vpp

4
RA3/MCLR/Vpp

1
Vpp

12 V pulse

CLOCK

12
RB6

12
RA1 / ICSPCLK

18
RA1 / ICSPCLK

5
RB6


DATA

13
RB7

13
RA0 / ICSPDAT

19
RA0 / ICSPDAT

4
RB7

 


Adapter
Note: If you already built the adapter for the PIC12F675 (with 8 pins), you can program the PIC16F684 (with 14 pins) with it, too. Pin 1 of the PIC plugs to pin1 of the socket. Pin 14 of the PIC16F684 plugs into pin 8 of the PIC12F675 adapter. Looks ugly but works .



Contents


Adapter for PIC18F2455 / PIC18F2550 (28 pin SDIP)

This adapter was used to program a PIC18F2550 with 28-pin SDIP case, using a programmer which was originally built for the 16F84/16F628. Though these chips have a USB interface, you cannot program them through USB (without extra hardware or a special bootloader).

Beware: The pinout of these PIC18F2x5x devices looks similar to other 28-pin PIC16F devices and dsPIC's on first sight, but they are not pin-compatible ! The following table helps to build an adapter for PIC18F2455 and PIC18F2550 devices, to be programmed with an old 18-pin PIC programming interface. I tested it with a JDM-style interface and it worked ok.

Adapter from 18-pin PIC16F programmer to 28-pin PIC18F2550 (and similar)
Pin Function Pin Nr & Name
PIC16F628 (SDIP 18)
Pin Nr & Name
PIC18F2550 (SDIP 28)
Remarks
Power supply

14
"Vdd"

20
"Vdd"


Ground

5
"Vss"

8, 19
"Vss"

connect all "ground" pins !

Prog Voltage

4
MCLR/Vpp

1
MCLR/Vpp/RE3

12 V pulse

CLOCK

12
RB6

27
RB6/KBI2/PGC

connect 22 .. 47 pF cap
to ground (*)

DATA

13
RB7

28
RB7/KBI3/PGD

 connect 22 .. 47 pF cap
to ground (*)

LowVoltage
Prog.mode

-

26
RB5/KBI1/PGM

pull to GROUND to avoid
entering low-voltage prog mode

Note: You don't necessarily have to connect RB5/KBI1/PGM to ground. But doing so makes sure the chip doesn't enter low-voltage programming by accident, because WinPic only uses standard ("high-voltage") programming at the moment.

Contents


Adapter for dsPIC30F201x (28 pin SDIP)

Beware: The dsPIC30F2010's pinout looks similar to other PIC16F and PIC18F devices on first sight, but it is not compatible ! The following table may help to build an adapter for most dsPIC's with 28 pin standard DIP case, to be programmed with an old 18-pin PIC programming interface:

Adapter from 18-pin PIC programmer to dsPIC30F2010 (and similar)
Pin Function Pin Nr & Name
PIC16F628 (SDIP 18)
Pin Nr & Name
dsPIC30F2010 (SDIP 28)
Remarks
Power supply

14
"Vdd"

13, 20, 28
"Vdd" and "AVdd"

connect +5V to all supply
voltages, analog and digital !

Ground

5
"Vss"

8, 19, 27
"Vss" and "AVss"

connect all "ground" pins,
analog and digital !

Prog Voltage

4
MCLR/Vpp

1
MCLR

12 V pulse
(dsPIC only needs 9 V)

CLOCK

12
RB6

18
PGC / EMUC / U1RX / ...

connect 22 .. 47 pF cap
to ground (*)

DATA

13
RB7

17
PGD / EMUD / U1TX / ...

 connect 22 .. 47 pF cap
to ground (*)

(*) About PGD and PGC filtering: There was a note on the Microchip forum (by Olin Lathrop) about programming the dsPIC30F201x(**), suggesting to put 22..47 pF on the PGD and PGC lines to ground near the target chip. In addition, put a 100 ohm resistor in series with the PGD line between target chip and the cap. The resistor and cap on the PGD line low pass filter the PGD signal when it is driven by the target chip. This reduces the high frequencies that can couple onto the PGC line. The cap on the PGC line makes it less suceptible to coupled noise.
(**) We later found out that this important note also applies to the PIC18Fxxxx family. A user of a Velleman PIC programmer reported success with a PIC18F4520 after adding 2 * 33 pF caps and a 100 Ohm series resistor.

The PGD / PGC filtering components are shown in the circuit diagram of DL4YHF's modified programmer for the serial port.

Contents


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 64k WORDs.

At the moment, most FLASH-based PICs with 14-bit code words, and a few 12-, 16-, and 24-bit devices have been tested. If your copy of WinPic is older than a few months, look for an update on the author's ham radio/ homebrew homepage.

Contents


The file DEVICES.INI

This file can be modified to make WinPic support a new PIC device. To add support for a new device which is not directly supported by WinPic,

The format of the file DEVICES.INI is explained in a separate document, along with the description of the parameters which must be added new PIC devices. Note: WinPic once loaded this file through a Windows API routine, but I changed this after the file grew too large, because Win98 can only read INI-files up to 64 kByte (why??) - so now DEVICES.INI is parsed line-by-line as a textfile.

Device definitions in DEVICES.INI will override the built-in definition table. So, if you find there is a bug in a device definition, add it into DEVICES.INI to let WinPic ignore its internal PIC device table. A message will be displayed in the status line and in WinPic's "Message" list.

Contents


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/
Johan Bodin's site (=SM6LKM homepage) where his 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.bknd.com/
B. Knudsen Data have a nice -possibly the best- C compiler for PICs. For small, non-commercial projects (max 1024 instructions) the free version is worth a try, but beware - don't expect a full ANSI C implementation which wouldn't make sense with the PIC's limited addressing modes anyway. The CC5X compiler can be integrated into the newer MPLAB versions, even source level debugging using the simulator is possible.
???
Once there were David Tait's excellent PIC pages, but David has stopped updating the site. Unfortunately the mirror sites have dissappeared in 2004. The same is true for some other PIC links - no signs of recent life there. So use your favourite search engine to look for "David Tait's PIC Archive", there may be some copies of it somewhere.
http://www.qsl.net/dl4yhf/winpicpr.html
The author's HAM RADIO homepage where you'll find the latest release of this program, and my up-to-date email address. If that does not work search the web for "Wolfgang Büscher DL4YHF" or "DL4YHF WinPic" - just in case I changed my ISP again.

Contents


Revision History (with dates in ISO format: YYYY-MM-DD)
2000-09-16 : First ever released version of WinPic. Supported most EPROM-based chips.
2005-02-19 : Added support for dsPIC30F
2005-05-01 : Added support for PIC10F20x ... totally different 'programming spec', as usual
2005-04-XX : Support for PIC18Fxxxx added by Martin van de Werff
2007-06-03 : A.Kibler added support for PIC12F609/615,16F610/616, ..
2008-xx-xx : Development virtually came to a halt, in favour of ARM7, Cortex-M, etc
2015-12-29 : Added the 'clock feedback' to defeat problems with USB <-> Serial Port adapters

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