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"
!)
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.
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).
The main window of the Pic Programmer consists of several "tabs":
If you have ever used PIP02, you will find almost the same functions and menu structure in this programmer.
The usual operation sequence is:
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.
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).
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:
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
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).
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 !
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
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 ;-)
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.
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:
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 |
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 |
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:
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
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.
(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 !)
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:
Pin Function | Pin Nr & Name PIC16F628 (18 pins) |
Pin Nr & Name PIC12F675 (8 pins) |
Remarks |
Power supply |
14 |
1 |
+ 5 V |
Ground |
5 |
8 |
don't say |
Prog Voltage |
4 |
4 |
12 V pulse |
CLOCK |
12 |
6 |
|
DATA |
13 |
7 |
|
:
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.
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 !!!
--... ...-- ...-.-