2
\$\begingroup\$

I am working with a PIC16F723A chip and I am trying to program it to toggle a pin (RA1) on and off. I am pretty sure I have the circuit setup correctly (below is what I have setup), but for some reason I get an error when trying to program it....

So, I am using MPLAB X IDE v1.70 on OS X version 10.8.2. The project configuration in MPLAB X is setup with the device of PIC16F723A, hardware tools of ICD 3, and compiler toolchain as XC8 (Location: /Applications/microchip/xc8/v1.12/bin). There is no supported plugin board. It is NOT setup to power the target circuit from the ICD 3.

The error I am getting is "Connection Failed.If the problem persists, please disconnect and reconnect the ICD 3 to the USB cable. If this does not fix the problem verify that the proper MPLAB X USB drivers have been installed."

The warning I am getting is "CAUTION: Check that the device selected in MPLAB IDE (PIC16F723A) is the same one that is physically attached to the debug tool. Selecting a 5V device when a 3.3V device is connected can result in damage to the device when the debugger checks the device ID. Do you wish to continue?"

Here is how I have the circuit setup...
PIC16F723A PIN 1 is connected to ICD3 MCLR PIC16F723A PIN 28 is connected to ICD3 ICSPDAT PIC16F723A PIN 27 is connected to ICD3 ICSPCLK PIC16F723A PIN 1/ICD3 MCLR is connected to external VDD (+3.3V) through a 10K resistor (I have also tried a 4.7K) PIC16F723A PIN 8 is connected to PIC16F723A PIN 19 PIC16F723A PIN 19 is connected to GND PIC16F723A PIN 20 is connected to VDD (+3.3V)

I am checking the chip using a Tektronix Oscilloscope and when I continue from the warning message, I see data being transfered on the ICSPDAT pin, but nothing has changed for the RA1 pin.

Here is the code I am using:

#include <stdio.h>
#include <stdlib.h>
#include <pic16f723.h>

void main(void){
     int i = 0;
     TRISAbits.TRISA1 = 0; // RA1 to output
     ANSELAbits.ANSA1 = 0; // RA1 to Digital I/O

     while(1){
         PORTAbits.RA1 = 1;
         for(i = 0; i < 1000; i++);
         PORTAbits.RA1 = 0;
         for(i = 0; i < 1000; i++);
     }
}

I have checked the circuit design several times, I have checked to make sure the chip is correct (the silkscreen on it says PIC16F723A-I/SP 1142D3V). I have also tried programming it by supplying +3.3V from an external supply and a +5.0V from an external supply.

Here is the schematic: enter image description here

Where I have attached an oscilloscope to SCOPE

I have tried the ICD3 test interface board and it came back saying everything is working correctly:

Test interface PGC clock line write succeeded.

Test interface PGD data line write succeeded.

Test interface PGC clock line read succeeded.

Test interface PGD data line read succeeded.

Test interface LVP control line test succeeded.

Test interface MCLR level test succeeded.

ICD3 is functioning properly. If you are still having problems with your target circuit  please check the Target Board Considerations section of the online help.

I have been able to successfully program a PIC16F1824 chip with this programmer and computer. I am using a PIC16F723A because I needed more I/O pins than the PIC16F1824 has. I have also used this computer to successfully program a Cerebot MX4cK. For some reason the PIC16F723A doesn't want to work. If I haven't mentioned it before, I have tried multiple chips.

\$\endgroup\$
  • 1
    \$\begingroup\$ Provide a schematic! \$\endgroup\$ – Leon Heller Mar 23 '13 at 19:09
  • 1
    \$\begingroup\$ Is that your entire code? Have you set the config bits? For example have you turned the WDT off? A schematic would be easier to understand. It sounds like your ICD3 power pins may not be connected to the targets +3.3V/ground. Also, if you have just changed from MPLAB you need to run the driver update IIRC. \$\endgroup\$ – Oli Glaser Mar 23 '13 at 19:34
  • \$\begingroup\$ I have attached a schematic. That is all of the code, I tried setting the WDT config bit off (bit set to 0) and it didn't make a difference. \$\endgroup\$ – mightymouse3062 Mar 23 '13 at 21:14
  • \$\begingroup\$ could the compiler be optimizing out you for loop? \$\endgroup\$ – Grady Player Mar 23 '13 at 21:48
  • \$\begingroup\$ Doubtful, I tested this loop on another PIC (PIC16F1824) and it works without a problem. I think the problem is with it not recognizing it as the correct device (See warning above) \$\endgroup\$ – mightymouse3062 Mar 23 '13 at 23:05
2
\$\begingroup\$

It is NOT setup to power the target circuit from the ICD 3.

AN910 is a good reference on programming a PIC. It's worth a read, especially if you're having problems.

That being said, the most reliable way I know of to program PICs is to power down (i.e. disconnect the power source) and allow the programmer to provide power to the device.

There should be no problem powering your circuit from the ICD3. If there is (i.e. there's other load on the rail that the ICD3 cannot handle) then you may need some circuitry to isolate the rest of the VDD rail from the programming header (schottky diode or something similar) to facilitate programming.

\$\endgroup\$
0
\$\begingroup\$

The warning I am getting is "CAUTION: Check that the device selected in MPLAB IDE (PIC16F723A) is the same one that is physically attached to the debug tool. Selecting a 5V device when a 3.3V device is connected can result in damage to the device when the debugger checks the device ID. Do you wish to continue?"

This message is displayed whenever you connect if the selected part is a 5V device. If you only use 5V devices it is unimportant.

"Connection Failed.If the problem persists, please disconnect and reconnect the ICD 3 to the USB cable. If this does not fix the problem verify that the proper MPLAB X USB drivers have been installed."

It's common to have to disconnect and reconnect the ICD 3 occasionally. I don't think that indicates any specific problem.

Never mind your code or your board for the moment. Can you even connect to the Test Interface Module that came with your ICD 3?

Under Programmer > Settings... > Status there is a "Run ICD 3 Test Interface" button.

IDC 3 Test Interface Module

If that doesn't work, there's something wrong with either the IDC 3, your USB connection, or the ICD 3 driver. Are you using a USB hub? Try connecting directly to the computer.

\$\endgroup\$
  • \$\begingroup\$ The ICD3 has been directly connected to the computer (USB 2 port), no USB hubs or any of that. \$\endgroup\$ – mightymouse3062 Mar 31 '13 at 13:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.