'count.zip' contains some simple test code to help learn how
to program and burn a PIC 16F84(A) microcontroller.
David Tait, the 'father' of the cheap PIC programmer, previously
distributed an example schematic and simple test program for shaking
out the coding/assembly/burn cycle for these devices. (These can be
found in the 'TAIT-test' subdirectory of this zip archive.) His
program, 'walk.asm', repeatedly cycles through a set of 4 LEDs.
I've written a slightly more complicated test program for this same
hardware, 'count.asm', which counts in binary from 0 to an upper bound
you select (in the 'maxctn' constant) up to 0fh and then blinks
several ('blinkcnt') times. I wanted to illustrate a couple of ideas
that PIC newcomers might find useful to see:
- Use of the MPLAB standard device include file.
- Symbolic definition of program parameters ('blinkcnt' and 'maxcnt').
- Dynamic reprogramming of the prescaler.
- Use of subroutines to localize repeatedly used code.
- Use of logical operators for masking and subtraction.
- Implicit and explicit testing of Zero flag.
- Embedding RCS version information in EEPROM.
One important note: My code is setup for a crystal oscillator rather
than an RC network as found in the original circuit. I found that the
capacitance of the prototyping board I was using dominated the very
small capacitance needed for the RC oscillator - the circuit ran with
*no* capacitor. This gave me some concerns as regards to oscillator
stability, so I switched to a crystal. If you are using an RC
oscillator as David Tait's original circuit suggests, simply change
__CONFIG to 3ff7H and reassemble 'count.asm'.