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.

Contents

Start MPLAB

Do not connect the programmer to the circuit yet.

Plug in your programmer. Start MPLAB.

Select the PIC

Mplab1.png

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

Mplab2.png

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


Choose the programmer

Mplab4.png

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

Connect to the programmer

Mplab3.png

Go to Programmer->connect.

Mplab5.png

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

Mplab6.png

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

Load the firmware

Mplab7.png

Go to file->import.

Mplab8.png

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

Program the PIC

Mplab9.png

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

Mplab10.png

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

MplabConfigMenu.png

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

MplabConfigBitWindow.png

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.

DeviceMangerCOMProps.png

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

DeviceManagerDisableFIFO.png

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