	    TOPIC: A System to Try Out PIC Microcontrollers
	    ===============================================

			       David Tait

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


The TOPIC system is a very convenient way to learn about the Microchip 
PIC16x84 microcontroller.  TOPIC is a combination of a small circuit 
board that connects to the printer port of an IBM compatible PC and a 
program to control the board.  The hardware includes both a PIC16x84 
microcontroller development circuit and an on-board programmer.  The 
associated software downloads programs to the PIC16x84 in the form of 
Microchip hex files (either INHX8M or INHX16 format) and controls the 
execution of the PIC.  Alternatively the TOPIC board can be used as a 
standalone PIC16x84 programmer or, by not including the programmer 
components, a standalone PIC development circuit.  

The programmer reserves two of the PIC's I/O pins (RB6 and RB7) and 
these are unavailable for general purpose use.  However, if the TOPIC 
board is disconnected from the target circuitry during programming, and 
disconnected from the PC while running, all I/O pins are available.  
Despite the loss of two I/O pins, running programs while the board is 
still attached to the PC offers the most convenient mode of operation.  
The I/O pins are not wasted because when the board is connected to the 
printer port it is possible to use RB6 and RB7 to communicate with the 
PC as an aid to debugging.  

The schematic for the TOPIC hardware is provided in the Windows 
Paintbrush viewable file TOPIC.PCX. If you don't use Windows and need a 
DOS-based utility to view the files then you might consider the PICEM 
package by John Bridges - look for PICEM27.ZIP on any SimTel site.  The 
files COPPER.PCX and LAYOUT.PCX give details of a printed circuit board 
design for the TOPIC hardware (The schematic shows a crystal oscillator 
setup but the board can accommodate crystal, ceramic resonator or RC 
oscillator components).  All the PCX files have a resolution of 300 dots 
per inch (dpi) and should give good quality artwork on most printers.  
All the components to populate the board are available in the UK from 
Maplin Electronics.  

The software is supplied as a pre-compiled executable file (TOPIC.EXE) 
and as C source (in SRC.ZIP).  This release of the TOPIC software is
based on V-0.5 of my PP program (another 16x84 programmer).  The program
itself is described in the file PROGRAM.TXT but note that wherever that
file talks about PP.EXE you should read TOPIC.EXE.  There are just a few
features which are unique to the TOPIC hardware and these are outlined
below.

Running TOPIC with no arguments will pull the PIC reset line low.  Adding
-g to the TOPIC command line will execute the PIC program after download.
Alternatively the batch file RESET.BAT can be used to apply a short reset 
pulse.

The behaviour of the TOPIC system can be changed by some environment 
variables: 

	PPLPT=nn     The LPT port to use (default nn=1).  Can be 1, 2 or 3.
	PPDELAY=nn   Adds a delay of nn*0.83 microseconds to printer
		     port accesses (default nn=6).  Useful for fast PCs.
		     The valid range of nn is 0 to 127.
	PPDUMP=nn    If nn=16 files are dumped in INHX16 format (default
		     is INHX8M).
	PPDEBUG=nn   Enter debugging mode if nn=1.  Used to confirm
		     hardware is operating correctly.  Don't use this  
		     mode with PIC installed.

It's probably best if the appropriate commands are included in a batch
file.  For example to increase the printer port delays and tell TOPIC 
to use LPT2 write a batch file as follows:

	@ECHO OFF
	SET PPLPT=2
	SET PPDELAY=100
	TOPIC %1 %2 %3 %4
	SET PPLPT=
	SET PPDELAY=

Before installing the PIC in the board run the software in debugging
mode by using DEBUG.BAT.  This will let you perform some static tests
on the hardware (simply hit any key to proceed to the next test).  In 
debugging mode the /MCLR, RB6 and RB7 pins are placed in various states 
so that the signal voltages can be measured to confirm correct operation.  
As the PIC is absent it may be necessary to connect a high value resistor 
(47k say) from /MCLR to GND to get sensible readings of the /MCLR voltage.  
You'll also need a 220 ohm resistor to test whether the PC can read the 
state of the RB7 pin (instructions are given by the program).  If you have 
problems getting things to work have a look at PROBLEMS.TXT.  If you want 
to know more about the hardware it is briefly described in HARDWARE.TXT.
Even though a PIC can source/sink around 20mA per I/O pin remember the 
TOPIC board VDD supply is taken from a 100mA voltage regulator so be
sensible about the loads you use.

The Files WALK.ASM and WALK.HEX are the source code and associated hex 
file for a simple test program you can use to exercise the TOPIC board.  
See WALK.ASM for details. 

6/Jun/1998                     
