TARGET INVALID ID on PIC18f66k40

Thread Starter

pjreijiri

Joined Aug 19, 2015
101
Hello,
I am trying to program a PIC18F66K40 that is already on a board. I made sure all the connections are correct. the pickit3 connects directly to the microcontroller. I made sure there are not cap or resistors in the wrong places. I flipped pin 4 and 5 on the connection between pic and pickit. Tried it on a mac and windows and still gives me:
"Target Device ID (0x0) is an Invalid Device ID. Please check your connections to the Target Device."

Any advice?
 

jpanhalt

Joined Jan 18, 2008
11,087
Here's what the datasheet for the PIC18(L)F66K40 shows (second column from the left is pin #):

upload_2019-4-22_17-58-41.png

upload_2019-4-22_17-57-14.png

Why are you connection Pins 4&5 of the target to the PICKit?
 

Thread Starter

pjreijiri

Joined Aug 19, 2015
101
I have tried LVP and HVP.
My wires are 3-4” long whatever that comes with the pickit
As for caps on VSW and vdd, I do have caps on them
 

jpanhalt

Joined Jan 18, 2008
11,087
Jpanhalt, pin 4&5 on the pickit
That's why we encourage people to show their schematic. Even if you meant "reversing" pins 4 & 5 on the PICKit, I don't have a clue what that means. Most logically, I assume you connected the PK3 CLK to the target DAT and the PK3 DAT to the target CLK. Is that what you did?

Please show your connections and decoupling caps.
 

jpanhalt

Joined Jan 18, 2008
11,087
The usual problems one sees is failure to turn off LVP and failure to ensure your programmer does not power the target (on my version a box to power target by programmer needs to be clear).

Aside from that, a decoupling cap between PK Vcc and Gnd and close to the PK may be needed.

Have you tried another chip, say a 16F series with your PK? Years ago, my first PK3 worked fine for a week or so, then stopped working. Microchip gladly replaced it free and offered an ICD3 at a substantial discount. I now have a virtually unused PK3 and rely on my ICD3. The PK3 did require a cap close to Vcc and Gnd for the chips (12F683 and 12F1840) I was using at the time.
 

Thread Starter

pjreijiri

Joined Aug 19, 2015
101
Well i have the board already assembled. I will restart from scratch on a breadboard, then a protoboard to test the capabilities and then design the PCB.
 

jpanhalt

Joined Jan 18, 2008
11,087
Restarting from scratch wasn't my idea at all. It wastes a lot of time and rarely will it find an error. That is particularly true if you are using the same PCB.

1) Do you have any PIC device on a break-out-board or with DIP pins. If so, write something (config, goto start, end) , hook it up, and see if it is recognized.
2) Use a multimeter to trace your connections to the chip, check for shorts to ground, Vcc (Vcc not connected while doing that), or other pins/devices.
3) Check again your programmer settings. Is the device set correctly? Same for code.

In other words, troubleshoot before re-doing. Ready, fire, aim rarely hits the target.
 

Thread Starter

pjreijiri

Joined Aug 19, 2015
101
1) I got a pic16f887 and connected it to my pickit3 and was able to turn on an LED, so that part seems to be working.
2) I tried to check the shorts, I still did not find anything.
3) I tried the HVP and it did not work. As for the code, I am just trying to upload this:
void main (){
return;
}

As for restarting from scratch, I am getting all the parts in through hole packages, I am going to try them on a breadboard, then protoboard and start building the whole project block by block. I usually do that, but this time I just skipped to designing the whole thing on Kicad and get it manufactured. Which I think was a bad idea but I trying to cut corners and save some time.

Any other idea that you think I need to check?
 

jpanhalt

Joined Jan 18, 2008
11,087
The 16F887 is HVP only. Your 18F can be LVP or HVP. It is LVP by default. You need to turn that off in your configuration (Config4,13). Are you doing that?
 

Thread Starter

pjreijiri

Joined Aug 19, 2015
101
So you could program it with the PICKIT3?
Yes I programmed the pic16f887 with my pickit3 and it worked. I only set RA0 to high output.

As for the pic18, I did go into the properties and set the programming to be HVP and still nothing happened. I’m going to try again tomorrow, just in case it’s one of those times where you just sleep over it and things would work out
 

jpanhalt

Joined Jan 18, 2008
11,087
When one sets configuration bits in the programmer, it is necessary to clear a toggle that lets the programmer override the code -- at least in old version 8.92 of MPLab. I would set in code just to be sure and as a record.
 
Top