TOPIC Hardware
==============

The TOPIC hardware consists of a simple serial mode programmer
combined with the minimum number of components to support PIC
operation.  The board connects to the parallel port of an IBM
compatible PC via six wires:

           TOPIC PL2         PC printer port
           ---------         ---------------
             pin 1           INIT     pin 16
             pin 3           D0       pin 2
             pin 5           STROBE   pin 1
             pin 7           AUTOF    pin 14
             pin 9           SEL/BUSY pins 11 & 17
        pins 2,4,6,8,10      GND      pins 18-25

I use a short length of ribbon cable with a 10-way IDC plug on one end
and a 25-way female D-connector on the other to connect the TOPIC
board to a standard printer cable.

PIC pins RB6 and RB7 are used for serial mode programming and are
directly connected to the PC via resistors R1 and R2.  The resistors
are there to protect the PC port drivers and ensure no harm will
result if the PIC enables RB6 and RB7 as outputs when it runs.  Unlike
most directly connected PIC programmers (for example, Mark Cox's
BLOWPIC and Derren Crome's programmer described in EPE) TOPIC can also
read the PIC contents.  Two other printer port pins are used for this
purpose: when RB7 is used as an input to the PIC the anode of D4 is
pulled to ground by the SEL open collector driver; when RB7 must be
read SEL is turned off and the anode of D4 is thereby raised to +5V
via the pullup resistors in the PC; now RB7 can pull the cathode of D4
low and hence also pull the BUSY input low.  This may sound cumbersome
but works rather better than the alternatives I tried.

Except during programming the LM317L is set to produce about 1.2V and
thus due to the diode D2 the /MCLR pin is held at roughly 5V or 0V
depending on the state of the transistor switch Q2.  To switch on the
programming voltage both Q1 and Q2 are turned off.  The programming
voltage should be set to about 13.5V by R7 and R8 and using 2% tolerance
resistors for these components is best.  If you use 10% tolerance resistors
you may need to select R7 to make sure the voltage doesn't exceed 14V.
When the the PC is not connected the bias components ensure that Q1 is on
and Q2 is off resulting in /MCLR being held at 5V; in this state the
PIC can be reset by power-cycling.  Note, an open-collector driver
(that guarantees 0V output) rather than one of the data outputs (that
doesn't) must be used to control Q1.

The TOPIC board can be used as a standalone programmer as it is but if
that's all it must do it's possible to save a few components.  For
example you can remove R4, R5, Q1, R13, D5, D2 (replace with a wire
link), X1, C6, C7, R9, D3 and PL3.  R11 and R12 are only there to
reduce dissipation in the 78L05 and in programmer only mode they can
be replaced with a wire link.  The result is probably the least
complicated of all printer port programmer designs (not as simple as
the serial port types though).  One problem with this setup is that
the PIC  must be inserted into a "hot" socket (i.e. +5V is
connected) but that's how some commercial programmers work too.
Don't use the /G switch with the TOPIC software when Q1 is not fitted.

The TOPIC board can be used as a simple (if large) PIC16C84 project
board by removing R1-R8, R10, Q1-Q2, U2, C4, R13, D2, D4-D5 and PL2.

Although RB6 and RB7 can't be used as general purpose I/O when the
PC is connected that doesn't mean they can't be used at all; you need to
design your application so that the circuitry that attaches to these pins
will not interfere with the programming process.  Here is what the circuit
looks like on a typical PC:

                       _____   open collector   _____
          +5V  +------[_____]--------O---------[_____]--------O
        PC internal     4k7       port pin       1K       RB6 or RB7

The 4.7k resistor is in the PC.  Thus the TOPIC board can pull RB6 (or
RB7) to 5V via roughly 6k or pull it to ground via 1k.  External
circuitry can be added provided that RB6 (or RB7) can still be pulled
below 1V and above 4V and this means it must present a load of no more
than 25K or so.  If you have an existing PIC target board that meets
this specification then the TOPIC board (with it's own PIC unplugged)
can be used as an in-crcuit programmer for that target.  It is a fiction 
that in-circuit programming can be applied without considering the
consequences; that goes for hardware like the AN589 circuit just as
much as it does for the TOPIC board.

I have found that I can leave the TOPIC hardware connected to the
printer port while the PC is switched on and also during CTRL-ALT-DEL
reboot cycles without problems.  However it is prudent to disconnect
the board or its power connection when the PC is switched off if you
want to avoid trashing the PIC contents.


David Tait
13th September 1996
