
   PICPROG

This program downloads a hex file into the PIC16F84 controller
from Microchip using a PC parallal port and simple hardware.
Should be compatable with PIC16x8x but wouldn't swear to it.

Usage: PICPROG [/?] [/D] [/P=xxxx] [filename.ext]

If run interpreted or without a command line it presents a
menu to choose program, dump or quit. If filename is omitted
then it prompts for one.

Switches...

  /? - brief help screen
  /D - dump PIC contents to a hex file
  /P=xxxx - specify HEX parallel port address (caution!)

Be careful using the /P switch, unpredictable things might
happen if not entered correctly. /P=0278 would specify port 2
on most systems, defaults to port 1 at 0378. Port addresses
must be a 4 digit hex number. If the programmer is on port
1 or 2 the program should find it by itself, use /P= only
if you have a non-standard system.

My 2nd port is at E000 (I don't know why, just is), 
so in a batch file "on the path" I have...

@echo off
a:\picprog\picprog.exe /P=E000 %1 %2 %3

...edit as needed to specify exe location and port number.

This program accesses hardware and requires MsDos or Windows 95/98. 
It won't run under XP or NT and running under Linux will require 
the ability to convince the OS and the emulator that it's allowed.
Which sounds easy, and should be, but is not so I boot from floppy.

PICPROG reads and produces standard intel-format hex files and
should be compatable with most other PIC software. I don't know
the exact name of the format, something byte-based since all the
addresses are doubled. Programmer-specific information is ignored.

The programming time constant is determined at startup, faster
computers take longer to compute to ensure it isn't too slow
running on slower computers. All the "real" timer routines I
checked out did funny stuff to the hardware timers, to avoid
conflicts this program tries increasing loop numbers until it
finds one that provides a long enough delay using the tick
counter for reference. Disk-intensive programs running in
other windows might cause it to guess wrong and produce
verify errors. (i.e. don't run while scandisk is running:)

All PIC locations are checked and programmed with verify if
different. Unspecified space is zeroed, therefore make sure
the hex file contains a configuration! This may be changed
in a future version but I kind of like it the way it is,
any decent PIC hex file should contain a config word, and
I prefer that unused space be cleared so I can recognise
programs by their dump.

An interesting situation occurs if you try to program a zeroed
file into a PIC - it doesn't work anymore! This happened when
I tried feeding it a 0-byte file before adding a check for that
situation... code protected zeroes. This program cannot undo the
"damage" so it issues a big warning before enabling code protection.
(other software can fix but I haven't figured it out yet:)

Please report any errors you might encounter so that I can
make appropriate changes, probably to the constants.


Schematic of the programming hardware:
(view this with a fixed-width font)


  Parallel Port                                        Robot
  -------------                                        -----

   2   D0 o---------------1K----------.
                                      |                 
   3   D1 o-------------------1K------|-----------------o RB6 Pin 12
                                      |
   4   D2 o-----------4.7K--.         *-----------------o RB7 Pin 13
                            |   c     |
   5   D3 o---4.7K---.      |   .-----|---.         .---o GND Pin 5
                     |      `-|<      |   |        _|_
  10  ACK o----------*      b  _|_e   |   |   .---------o +5V Pin 14
                   c |                |   |   |
  18- GND o--.        >|---15K--------'   *---|----*----o MCLR Pin 4
   25       _|_    e_|_ b          .--1K--'   |    |
                          .---*----*---470----*    |
  15-20v  >---------|>|---'  _|_+            _|_/ _|_/
   ac/dc  >---.              -.- 470u  5.1v //_\ //_\ 12v
             _|_             _|_ 25v    ZD   _|_  _|_  ZD

  transistors = 2N3904, 2N2222 or other NPN
  ZD = zener diodes, 1/2W  other diode = 1N4001 etc

If wiring to a bare PIC chip rather than in-circuit add
a 1uF capacitor (thereabouts) across PIC pins 14(+) and 5.


Current version: 11/18/2006
EXE size: 41,673 bytes

This is public domain software, do what you want, no guarantee.

Terry Newton
wtnewton@infionline.net
