Wednesday, 1 October 2014

Programming/downloading firmware to a Microchip PIC microcontroller using PICKit

Step 1: Download MPLABx IDE from:  http://www.microchip.com

Step 2: Install the download MPLABx IDE.

Step 3: Connect your PICKit programmer tool to the PC via USB cable.

Step 4: Connect PICKit with the board on which PIC microcontroller is soldered via given connector especially for programming the MCU. And power up the board.

Step 5: Run the MPLAB IPE. An icon should be added to the desktop after installation.

Step 6:  a. Select the target microcontroller that needs to be programmed, like e.g. PIC16F1824

             b. Click on 'Apply' button

             c. Then click on 'Connect' button

             d. If a prompt message appears asking for continue and if the target microcontroller is being powered by 5v, then click 'OK'.







If selected MCU is correctly defined above, connected correctly and powered up, then the output box should show this:



If in case, MCU isn't powered up or not correctly connected with the PICKit, then it should show the following output.




Step 7: Click the 'Browse' button beside 'source' label and browse the file location of the hex file which is to be programmed and select it.




Step 8: Click 'Program' button



The output box should show this:




Solution to PICKit 3 - ' Connection Failed ' problem

Many of the PICKit 3 users has faced the problem of getting 'connection failed' message, while trying to get it to work with Microchip's new IDE & Programmer utility, MPLABx & MPLAB IPE. There are various possible reasons for getting this error, some of the possible reasons are below:


1) Faulty hardware
2) Old or faulty operating system of PICKit 3 itself. That includes new PICKit that can also contain this faulty or old operating system.
3) Bad USB cable/connection, of PICKit 3 with PC. In this case, when PICKit 3 is being updated by MPLAB and due faulty USB cable or accidentally plugging it out causes the corruption of operating system of PICKit.


Solutions to fixing it:

If the PICKit 3 has some faulty hardware or if it is damaged, then solution below won't work.

1) First of all, make sure that USB cable isn't faulty and appears in MPLAB IPE in 'Tool' list like this:




2) Check if the Status LED on PICKit is either green or off. If it stays 'red' for more than 20 seconds, press (also try long press) the button on the PICKit. If it turns off or into green, then try connecting the PICKIT 3 again. If it still doesn't work, then try the next steps below.

3) Try installing the MPLABx IDE v2.05 or v2.20, then see if this version is successful in making connection or not.

4)  a. Download the archived 'Pickit standalone programmer utility from the link below:
http://ww1.microchip.com/downloads/en/DeviceDoc/PICkit_3_Programmer_1_0_Setup_A.zip

b. Install this utility, plug out your PICKit 3 from PC and then run the utility.

c. From 'Tools' menu, click 'Check communication'. See, if PICKit 3 is detected or if the utility shows some errors in the status box.

d. Then check if back in 'Tools' menu 'Download operating system' option is enabled or not. If it enabled, then click and it should open file select dialog box which should open in its installation directory showing ' *.jam' file. The .jam file is its operating system, select it. The utility starts downloading the firmware. Wait for couple of minutes to finish, until status box shows done.

e. Then click on 'check communication' again to see if utility finds the PICKit successfully or not. If it does, then you can use the same utility to program the MCUs or close it and run MPLAB IPE. MPLAB IPE/MPLABx IDE should also connect with PICKit 3 successfully and load the PICKit with newer OS automatically. 

5) PICKit 3, itself, is made by using a PIC MCU, PC24FJ256GB106. If nothing works, then there is option to program the PICKit 3's MCU itself with the help of another working PICKit or any other PIC programmer, which can program PIC24FJ256GB106.

a. Open the casing of target PICKit 3 and notice the 6-pin connector though-hole pads besides a PIC24FJ256GB106 on the PCB board.

b. Solder the wires on this pad.

c. On the other end, solder male 0.1' inch pitch male header pins or any other suitable connector which can be plugged into the working programmer, which will be used to download new program into the target PICKit 3's MCU.

d. Download the firmware/OS image from the links below. This .hex file will be used to programmed the target PICKit 3's MCU.
https://www.dropbox.com/s/oqsbzexso271bym/PK%203%20image%20new.hex?dl=0

e. Using MPLAB IPE, Pickit standalone programmer or any other utility incase of using PIC programmer other than PICKit, select the downloaded hex file and download/image file hex file into the MCU.

f. Disconnect the programming cable, and plug the target PICKit 3 back into the PC and see if, now, MPLAB succeeds in connecting to it or not