Programming PICs with a programmer

From DP

Jump to: navigation , search

Here's how to program the bootloader in most Dangerous Prototypes projects with a PICkit or ICD programmer from Microchip.



Do not connect the programmer to the circuit yet.

Plug in your programmer. Start MPLAB.

Select the PIC


Go to Configure->Select Device. Choose the PIC chip in the prototype.


The Bus Pirate, for example, has a 24F64GA002.

Choose the programmer


Go to programmer->select programmer and choose your programmer.

Connect to the programmer


Go to Programmer->connect.


MPLAB may want to download a new operating system to the programmer, that's OK.

Connect to the circuit

Power up the circuit, unless your programmer provides power. For example, connect the Bus Pirate to USB.

PIC programming header
Pin Name Function
1 MCLRReset and programming mode entry
2 V+Positive voltage
3GNDCommon ground
4PGDProgramming data (bidirectional)
5PGCProgramming clock

Now, connect the circuit to the programmer via the 5pin ICSP header.

  • Our standard pinout is shown in the table
  • MCLR is usually marked with a triangle
  • V+ might be from programmer to target, or target to programmer, depending on the configuration

Test the programmer


Go to programmer->connect again, this time it should detect PIC24FJ64GA002.

Load the firmware


Go to file->import.


Select the file to program. For the Bus Pirate, use BPv3-Bootloader-v4.x.hex from the most recent firmware download.

Program the PIC


Go to Programmer->program, the bootloader will be programmed into the PIC.

Disconnect the programmer

Disconnect the programmer from the ICSP header.

Upload a firmware with the bootloader


If you just programmed a bootloader, now upload a firmware with the bootloader. Follow the standard firmware upgrade process used with the project.

For example, place a jumper between PGC and PGD pins on the Bus Pirate and apply power. The MODE LED should light, the bootloader is ready. Upload a firmware with pirate-loader or ds30loader.

Tips and Troubleshooting

If Configuration bits aren't set in code


If your configuration bits aren't set in the source code, you can set them up using the MPLAB IDE Configuration Menu


Disable FIFO buffers for RS232 programmers

You'll receive a warning from MPLAB stating something like "make sure your system's FIFO buffers are disabled". This can be done by going to Device Manager, opening the advanced port settings for your COM port and disabling the buffering. Detailed steps as follows:

  • Right click on "My Computer".
  • Click properties->hardware tab->Device Manger.
  • Find "Ports(COM and LPT)".
  • Right click on COMx (where x is the com port your programmer is connected to).
  • Click properties.


  • In the PCI Serial port settings window, navigate to the "Port Settings Tab".
  • Click "advanced".


  • Uncheck the box labeled "Use FIFO Buffers".
  • RESTART YOUR COMPUTER before attempting to connect to your programmer.