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

			       David Tait

		      Electrical Engineering Labs
			 School of Engineering
			     The University
			  Manchester  M13 9PL
				   UK

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


		     Copyright (C) 1996 David Tait
		    8th September 1996 (preliminary)


The TOPIC system is a very convenient way to learn about the Microchip 
PIC16C84 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 PIC16C84 
microcontroller development circuit and an on-board programmer.  The 
associated software downloads programs to the PIC16C84 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 PIC16C84 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). The TOPIC program expects a string of 
switches (introduced by - or /) and single filename.  TOPIC is 
compatible with the __CONFIG, __IDLOCS and DE directives of Microchip's 
MPASM assembler; this means that using TOPIC to download a program can 
be as simple as: 

	TOPIC PROGRAM.HEX

where PROGRAM.HEX includes both the program and the configuration 
information.  It is possible to override (or specify) configuration 
information on the command line using one or more of the characters from 
the set (upper-case and lower-case letters are equivalent): 

	c    Enable code protection
	p    Enable power-up timer
	w    Enable watchdog
	l    LP oscillator
	x    XT oscillator
	h    HS oscillator
	r    RC oscillator

For example:

	TOPIC -PRX PROGRAM.HEX

programs the PIC with power-up timer, watchdog and XT (i.e. crystal) 
oscillator enabled.  Other command line switches include: 

	g    Go. Lets the PIC run (no file argument needed).
	d    Dump.  Dumps the PIC contents to the specified file.
	e    Erase.  Erases the PIC (no file argument needed).
	v    Verify-only.  Verifies the PIC against the specified
	     file contents.

Running TOPIC with no arguments pulls the PIC reset line low.  The 
Following batch file can be used to apply a short reset pulse: 

	@ECHO OFF
	TOPIC > NUL
	TOPIC -G > NUL

You can erase, program and run with a single command such as:

	TOPIC -EG PROGRAM.HEX
	
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).

It's probably best if the appropriate commands are included in 
AUTOEXEC.BAT.  For example to eliminate the printer port delays and tell 
TOPIC to use LPT2 use: 

	SET PPLPT=2
	SET PPDELAY=0

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.  



















