We’re basically ready to go ahead and check that everything works okay. If you have a lot of time on your hands, and you like being meticulous, grab a multimeter and check continuity on all the pins that are connected. With the PGC and PGD lines, I was told during a troubleshooting spree that it is advisable to check the resistance in these lines as well, apparently it needs to be below 1Ω. With no components and only a wire between the pin and the PICkit, I doubt that we’ll be having issues with too much resistance in these wires. This is Part 5 of the PIC32 tutorial. You can read Part 4 here if you haven’t already.
Plug in your programmer to the 6-pin header, and in turn, connect the PICkit 3 using a USB cable to your PC. You’ll notice a white arrow on the programmer, this is used to indicate the location of pin 1 on the device. Orient it so that pin 1 is connecting to the brown MCLR wire.
[responsive imageid=’246′ size1=’0′ size2=’600′ size3=’1000′]
If you haven’t downloaded MPLABX yet, you can download it from Microchip’s site. Once you’ve downloaded MPLAB X, it’s time to get installing. Run the installer and accept the defaults as you go. I won’t cover the installation in detail, as I’m sure it’s pretty easy to figure out.
MPLABX is a NetBeans based IDE, and the above installation also includes MPLABX IPE (Integrated Programming Environment). Start the IPE (not the IDE), and you should see something like the following screenshot:
[responsive imageid=’130′ size1=’0′ size2=’600′ size3=’1000′]
Filter out the PIC32 MCUs in the Family dropdown box, by selecting 32-bit MCUs (PIC32). Next, in the Device dropdown, select PIC32MX250F128B and click Apply. Let’s deliberately do this wrong, as I’m pretty sure, a lot of first attempts will turn out with the same mistake I made here. Click the Connect button, and watch the lights starting to flicker on the PICkit3.
You’ll be presented with an error message, that reads something like:
Target device was not found. You must connect to a target device to use PICkit 3.
The reason this is happening is because the MCU isn’t getting any power, and for that reason, the PICkit isn’t picking up the MCU. We need to tell the IPE application configure the PICkit 3 to supply power to the MCU.
To do this, you’ll need to log the IPE into Advanced Mode. On the main menu, select Settings > Advanced Mode. Next enter the password, the default is usually “microchip“. Click Log On, and you’ll see a range of new buttons appear.
Navigate to the Power tab, and select Supply Power. The defaults should be set to 3.3V already, so you should be okay there.
Now go back to Operate and click Connect. If everything has been done properly, this time around, you should see the following output:
Connecting to MPLAB PICkit 3... Firmware Suite Version.....01.28.92 Firmware type..............PIC32MX
Target detected Device ID Revision = A1
The success indicator here is the last two lines. First we see Target detected and lastly, Device ID Revision = A1. This last bit indicates that the PICkit was able to detect the device and retrieve it’s ID, which is used to identify the type of MCU.
If we received an ID back from the chip, it means we’re potentially good to go, it’s a good sign, but we’re not entirely out of the woods yet. The final tell tale sign, will be when we actually program the MCU with some useful code, and see it in action.
What can go wrong?
I won’t cover all the potential issues and pitfalls you may or may not encounter here.
Typical things that can go wrong include connecting the tantalum capacitor the wrong way around. Tantalum caps are typically polarised and you need to make sure you connect them the right way around.
I made the stupid mistake of short circuiting something on the breadboard, but it appears the PICkit 3 has some over current protection. MPLABX gave a warning that indicated that too much current was being sourced from the programmer. Don’t short circuit stuff, you might not be as lucky as I was. It’s not fun when you end up destroying an MCU you have to get a replacement posted to you. It takes about 3 days for stuff to reach me from my supplier, and normally, the postage fee is about 3 times as much as a single MCU. Not worth blowing it up! If you can, buy more than one MCU, most electronics suppliers give you discount when you buy for example 10 or more. In some countries, you should be lucky enough to be able to order free samples from Microchip.
Other issues can be in relation to the PICkit 3 programmer. I’ve been a victim of “Device ID == 0” errors, which initially lead me to believe that something was wrong with my circuit setup. Everytime I attempted to program an MCU, I either got an error message stating
Target detected Failed to get Device ID
I analysed and investigated every possibility. Attempts in replacing the MCU with a new one, suspecting the chip I was programming was bricked, didn’t give any different results. I completely removed and rewired my entire circuit, measured every connection for continuity, checked voltages with a voltage meter, and even confirmed that all my connections had a resistance of below 1Ω. Hours and days went to waste, until I finally decided to contact Microchip, and have the PICkit 3 replaced, since it was still under warranty. Microchip’s customer service was very brisk, and they had a replacement shipped to me within about a week and a half. The replacement fixed all my problems, and I’m hoping it stays that way.
There’s probably a host of other issues that can haunt an optimistic hobbyist, but hopefully, we should be ready to proceed to the next and final part in this tutorial.
In the next part, well cover adding an LED to the circuit, which we will light up with some code in the final step of this tutorial.