PIC Basics - Additional Information

PIC Programming
All PIC chips require programming before use. Programmers are available from a variety of sources or you can build your own. The PIC chip plugs into the programmer and the programmer plugs into a PC. Most programmers have serial ports but some programmers are available with USB and even with parallel (printer) ports to connect to the PC.
Loading the Program
To load the PIC chip, it must be placed into programming mode. This is done by putting 12.6 volts onto one of the pins, normally the 'Master Clear' pin. This has the effect of running a loader program in the PIC. Unfortunately, different chips have different loader programs and this can cause compatibility problems (see below).
Once in programming mode, one of the pins becomes a serial data input pin and another pin becomes a strobe pin. Normally, this is bit 7 of PIC port B for the data and bit 6 of PIC port B for the strobe.
Once the PIC is in programming mode, it can be sent commands. Each command is six bits in length. Some commands are followed by data. Depending on the command, this data could be an instruction to be loaded into the PIC's program memory, a memory address or a configuration command. Other commands have no data part. These can be used to erase the memory, to start the programming or to increment the memory address.
Configuration Bits
In addition to the actual program, PIC chips need a 'configuration word'. This tells the PIC chip where to get its clock from and whether to run Watchdog or Power Up timers. Note that the PIC always uses an internal clock whilst in programming mode. With MPASM, which comes with the Velleman kit, the configuration word can be placed on the top line of the program. Use the command "__config" (that's two underscore characters followed immediately by the word "config". Then add a space and the hexadecimal code that you want.
Compatibility
Unfortunately, there are many different types of PIC chip and there are different loader programs, even in apparently similar chips. Check the suffix of the chip type as well as the type itself. For example, a 16F73-1/SP has a different loader program from a 16F73-04/P.
Low Voltage programming
Some PIC chips have a 'Low Voltage Programming' mode. This allows the chip to be programmed without using a 12.6 volt supply. However, in order to use this mode, one pin must be dedicated to programming and cannot be used for input/output. Low Voltage programming mode must NOT be used for any of the projects in this book as these projects use the reuired pin for input/output purposes.
Further Information
Additional information about the programming of PIC chips is available from the Microchip web site


Click here to return to the PIC Basics Main Page