			     PP5X Version 0.2
			     ================

This archive contains the schematic of a PIC16C5X/XX programmer (UPP.PCX)
designed to be attached to the printer port of an IBM compatible PC.
Software for programming 16C54/55/56/57 chips is included as an example
of how to drive the hardware.  Some general comments about the hardware
can be found here:

    http://www.man.ac.uk/~mbhstdj/upp.html

Please note that this information is intended for experienced hobbyists
who can work directly from a schematic and are happy to experiment.  It
is not meant for beginners.  One problem area is that many PCs are now
equipped with sophisticated printer port hardware that can work in many
different modes.  If your PC is equipped with such hardware please make
sure that you know how to select standard printer port compatibility mode.
If you have built printer port projects before without problems then you
shouldn't have difficulty getting the programmer going.  However, before
you build this project remember that you cannot expect to get support
from me.  If you have any reservations about whether you can get the
programmer going please save yourself a lot of hassle and delete this
archive now.  Although I would be very glad to hear how you get on with
the project I must apologise in advance if I cannot find time to reply.
I can provide space on an FTP/WWW server for third-party enhancements to
this design and would particularly welcome PCB artwork or more
sophisticated software (even if you decide to levy a shareware fee).  I
am considering creating a support page on the Web and if you do e-mail
me about this project I reserve the right to add your comments to that
page.

The file PP5X.EXE is the programmer software and should be run under
MS-DOS (or a Windows DOS box) on anything from an XT to a Pentium.
When run the software will say:

    Rename PP5X.EXE as PPXX.EXE where XX is 54, 55, 56 or 57

That is you must rename the executable according to the PIC you want to
program (this feature needs MS-DOS 3.0 at least to work and if you are
still using an earlier version of DOS you will need to change the source
and recompile).  Let's say you are working with the PIC16C54 then you can
get the correct version of the software by running:

    REN PP5X.EXE PP54.EXE  (or COPY PP5X.EXE PP54.EXE)

The software gets some information about the hardware from the
environment: the LPT port to which the hardware is connected; and whether
separate sockets are available for 18 pin and 28 pin PICs (this variation
of the hardware doesn't need the switch shown in UPP.PCX).  To simplify
the hardware the one socket version scrambles the PIC data when 18 pin
PICs are inserted.  If two sockets are available the data should not be
scrambled (get Microchip datasheet DS30190 to find the correct wiring
if you decide to use two sockets; note the UPP.PCX signal SDA corresponds
to /PROG/VER and SCL to INCPC).  By default the software assumes LPT1 and
that a common socket is used.  To change the LPT port assumption use:

    SET PPLPT=n   (where n is the port to use and 1 <= n <= 3).

If your hardware has two sockets use:

    SET PPSOCK=2

If you want to make sure these are set permanently add the commands
to AUTOEXEC.BAT.  Alternatively change the source and recompile.  Once
the environment variables are set correctly run PP54 (or whatever) to
initialise the port and hardware.  If all is well you will see this
banner:

PIC16C5X Programmer  Version 0.2  Copyright (C) 1996 David Tait.

Usage: PP54  [ -lxhrwcdbv! ]  hexfile

       Config:   l = LP,   x = XT,    h = HS,    r = RC
		 w = WDTE, c = code protect
       Others:   d = dump, b = blank check, v = verify only, ! = no wait
       Defaults: RC, /WDTE, not protected, wait

Bug reports to david.tait@man.ac.uk

If the hardware is not found or fails some simple tests the banner
will not appear and an error message will be printed.  (The error
message should be printed if the hardware is not powered up but
I have found that some printer ports will actually provide enough
power to permit the hardware to pass the tests - very confusing.)
The software will complain if the hardware has only one socket and
you are trying to program an 18 (28) pin PIC with the hardware
configured for 28 (18) pins.

Using the software can be as simple as:

    PP54 PROG.HEX

where PROG.HEX is the PIC program in Microchip hex format (the software
recognises and loads both INHX8M or INHX16 styles).  One way of
producing the required hex file is with MPASM which is Microchip's free
PIC assembler (visit http://www.microchip.com for more details).
The hex file can also specify the configuration word and four ID words;
if they are present they will be used (the MPASM __CONFIG and __IDLOCS
directives are supported).

If the configuration word is not present in the hex file then the defaults
are used (i.e. select RC oscillator and disable the watchdog and code
protection).  The configuration word can also be set from the command line
using the appropriate switches (one of -r, -x, -h, -l for the oscillator,
-w to enable the watchdog and -c to enable code protection; upper and lower
case letters are equivalent).  Setting the configuration on the command
line overrides the hex file settings (this might be confusing if you
subsequently try to verify the PIC against the same file but without using
the same switches).

By default the software doesn't check if the PIC has been erased (i.e.
is blank) but the -b switch enables a check before programming or can be
used on its own to perform a blank check without programming.

Normally the software waits for you to insert a PIC but the -! switch
will skip the wait.

The PIC contents can be dumped to a hex file (INHX8M format) using the
-d switch.

The software verifies that PIC memory is programmed correctly as it
progresses but the -v switch can be used to perform verification-only
(code-protected PICs should be verified against a dump of a known
working protected PIC).  As shown in UPP.PCX the hardware can only
verify at the same VDD as used for programming.  The Microchip
programming algorithm calls for verification at the limits of the
intended operational VDD.  A programmer (like this one) not meeting
this requirement is called a prototype or development programmer.

Blank check, dumping and verification are blindingly fast and even
programming a 16C57 (2K words) is accomplished in seconds.

Here are some examples of how the software can be used:

    PP54 -XW! PROG.HEX  (select XT oscillator, enable watchdog, no wait)

    PP54 -B             (check PIC is blank)

    PP54 -D PIC.HEX     (dump PIC to PIC.HEX in INHX8M format)

    PP54 -V PROG.HEX    (verify PIC against the contents of PROG.HEX)

    PP54 -BCL PROG.HEX  (blank check, select LP oscillator and protection)

Using hex files with embedded configuration is recommended because then all
you need to do to program a blank PIC (with PROG.HEX) is:

    PP54 PROG.HEX

The hardware/software has been tested on a few PCs but most extensively
on a Toshiba T4800CT laptop (486DX4-75).   I have programmed 16C54s,
16C55s and 16C57s without problems (and with different software, 16C61s,
16C73s, 16C74s and 16C84s); the PICs I used were erasable (JW package)
but the programmer should work with one-time programmable (OTP) parts.
I don't advise trying to debug your version of the hardware using OTPs :-).
Note that OTP PICs (apart from the RC versions) will not allow selection
of just any oscillator type.  You should be careful to see that you do
not use inappropriate command line switches or hex files with the wrong
embedded configuration word; it's easy to make useless PIC-shaped trinkets.

An MPASM compatible assembler file (WALK5X.ASM) and an MPASM generated
hex file (WALK5X.HEX) are included with this archive.  Read the
comments in WALK5X.ASM for more information about how you can make
your own PIC test circuit to try out the programmer.

The programmer information and software are both free for non-profit
personal use (commercial exploitation must have my permission - please
respect this).  Like anything that is free it comes without warranty of
any kind.

David Tait                                           26th November 1996
Electrical Engineering Division
School of Engineering
The University
Manchester M13 9PL
UK

david.tait@man.ac.uk
http://www.man.ac.uk/~mbhstdj
