PIC Programmers, In Circuit Programming and BootLoaders

This is an article in the process of creation, will you help finish it?

In the PIC world programming may mean either writing the program by a human being or writing the hex file from the compiled ( assembled ) program into the PIC chip. This page concenrns the latter.

Overview
There are several different methods of programming each with its own advantages and disadvantages. Right now I like serial bootloading the best, but it may not be the best for everyone. The following chart summarizes the methods, they are then discussed in more detail later.

Hardware Programmer
Advantages


 * There is some programmer for every chip, and many support a very wide range of chips including one time programmable chips.

Disadvantages


 * Need to remove PIC from its circuit and put in the programmer's socket.
 * Extra cost for the programmer.

for links to programmers see: PIC Links search for "Programmer"

In Circuit Programming
Advantages


 * Do not need to remove chip from the PIC circuit.

Cypress says "ISSP ... stands for In-System-Serial-Programming. We recommend that all PCBs be designed to support ISSP. During the prototyping phase it is very convenient for the hardware of software engineer to be able to re-program a PSoC device on the prototype board. This is much easier than removing the PSoC device, reprogramming it and replacing it on the PCB. This is especially true when using surface mount devices." -- Cypress "Programming a PSoC In System"

"Atmel AVR910: In-System Programming"

Disadvantages


 * Not all chips support in circuit programming.

Serial Bootloaders
Advantages


 * Do not need to remove chip from the PIC circuit.
 * Often only requires you to shift the PC software to the Bootloader utility.
 * Very quick for test, revise, retest cycles.
 * No special hardware required, cheap.

Disadvantages


 * Not all chips support in serial bootloaders.
 * PC may not have the required serial port.
 * Requires serial hardware, but your circuit may already have it.
 * You may have to compile or assemble your bootloader to configure it for your needs, it may not be in the same language you would normally use.

With a Serial Bootloaders there are two software components ( in addition to the hardware serial connection ) the Bootloader utility running on the PC and the PIC bootloader on the PIC. If you program is going to use a serial interface any way ( even if just for debugging ) this can be a very nice way of programming, you do not have to move one bit of hardware to go from programming to running to programming to ....... The bootloader is a small program that is tucked away, normally in high memory, that checks at startup to see if it is connected to a PC bootloader utility. If so it dowloads a new program to the PIC, else it it runs the PIC program.

The PIC bootloader must be configured for the target chip and the configuration of the PIC, generally speaking the user program must share the configuration of the bootloader as the bootloading process does not change the configuration. Because of this bootloaders are often distributed in source code form ( usually asm ) so that you can tweak the code and assemble it for yourself. Often there will be several pre-built hex files and one of these may or may not work for you. Once you have the right bootloader you use a Hardware Programmer to write the bootloader to the PIC for hopefully the first and last time ( a badly behaved program can destroy the bootloader requiring a reload ).

In some cases you may buy a chip that already contains the bootloader -- this can save a certain amount of work.

The following is just draft:

You may be able to use a bootloader at a different baud rate than intended if the crystal is different. Both need to change by the same factor.

Tested Bootloaders
Tested tool chains for Serial Bootloaders -- if you Chip/Hardware is close this might be a good place to start.