Wednesday 28 February 2018

“Failed To Program Device” using PIC micros — 10 tips

If you work with PIC microcontrollers, you almost certainly encounter this problem. A seemingly innocent setup that worked fine yesterday suddenly refuses to program your PIC.

The cause of this issue varies a lot, but personally I blame the drivers controlling the hardware programmer. Some of these “fixes” really shouldn’t be necessary.

For reference, I am using a REAL-ICE programmer targeting a PIC18F, but I don’t think it matters much.

Here are 10 things to try which have worked for me:
  1. “Reset” the hardware programmer in your project properties - seems to work a lot!
  2. Unplug/replug hardware programmer/try again (lots of times, don’t be shy!)
  3. Check programming cable for flaws (mine is hand made and has failed before)
  4. Check DC supply power with a multimeter (is your power supply working right?)
  5. Check voltage to the microcontroller - is your circuit loaded any differently? Are you powering that off anything that’s busier today?
  6. Use mplab-ipe to perform a full erase, blank check… Repeat step 2 if blank check fails until it doesn’t
  7. Use dedicated port / powered USB (could be 500mA port current limit)
  8. Try changing all your other leads too, just in case
  9. Look for flaws around the programming lines leading to the micro (beep test using multimeter is very useful)
  10. Restart your computer (unlikely to help but worth a try… Sometimes an errant process holds on to the driver)
Finally, stay cool headed and remember it probably will work soon. Well, eventually. Maybe. For a little while.