This is where I talk about my forays into the world of Microchip Incís PIC microprocessors.

Download the file to get all the files referred to in this document.

In the first few months of 2000 I put together a bootloader program for the PIC16F874/877; a full description is in bootload.htm. Logically enough, the program is called BOOTLOAD, and the original C code is available in the ZIP file; to compile it youíll need the header file (also included) containing the defined locations Iíve used. The program was written for the Custom Computer Services C compileróofficially the "CCS PCM C Compiler, version 2.682". I canít promise that it will work with any other compiler.

A potential problem in the use of a bootloader with the PIC processor is that the processor has a configuration wordósometimes called "fuses"ówhich cannot be programmed under software control. The configuration word is normally "built into" the user code, but this is impossible when user code is loaded via software. What I have done instead is to attach a "lowest common denominator" configuration word to BOOTLOAD; if this is not satisfactory, you must modify and recompile BOOTLOAD. The configuration word is:

I have also included two hex files (i.e. the compiled version of the program, ready to load to a processor) for BOOTLOAD, one each for 4K and 8K memory components. Unfortunately, I canít create a hex file for every clock frequency anyone might use, so if you want any oscillator other than 20MHz youíll have to modify the C code and recompile it. There are two lines to change for different crystal frequencies:

#use delay(clock=2000000)

#define DELAY 45

Both of these lines occur near the start of the program.

BOOTLOAD is loaded into the PIC processor memory and normally doesnít have to be touched again. Subsequent loading and re-loading of user code is done over a serial port.

To run the loader there must be a companion program running on a computer. I have written such a program, PROG.EXE, which is also in the ZIP file. Itís a DOS program which takes a command line of the form:

PROG [1|2] [yourfile.hex].

The first argument names the serial port to use, and the second one names a file to send to the PIC, normally a file in Intel 8-bit hex format. If these arguments arenít given, the program prompts for them. The order of arguments doesnít matter. Many users will employ the MPLAB environment available free from Microchip. For these users, PROG (together with its arguments) can be run under the "Tools-DOS Command to Window" menu.

If you prefer to write your own companion program, details on communication requirements can be found in bootload.htm.