TARGET INVALID ID on PIC18f66k40

jpanhalt

Joined Jan 18, 2008
11,087
I use MPLab 8.92 which is older. I suspect you use MPLab X or something newer.

The header has a tab for "Configuration" . A dropdown allows you to select the device. Another dropdown allows you to set the Configuration Bits. My 8.92 version does not show the 18(L)F66K40 or 18F66K40. If I look at 18(L)F46K22, it shows:

upload_2019-4-24_1-30-7.png

If one disables the LVP here, you need to also uncheck the box at the top; otherwise, it defaults to what is in the code.

Now, if your device is actually an 18F66K40 and not the 18(L)F66K40, it may not have that option shown. I assumed earlier, that it was the LF version and cannot find a datasheet for the non-(L)F version. To make matters even more confusing, the 18(L)F66K80 that MPLab8.92 does show, does not show an LVP option in the dropdown.

If your IDE does not show an LVP option, I would write my configuration words out and clear (inactivate) the LVP bit. If you do that with a chip that is not LVP capable, you may get an error, but I have no way to test that. It seems more likely that since the LVP bit is the MSB that word, there will be no error created.
 

spinnaker

Joined Oct 29, 2009
7,830
Is this a real PicKit3 or a clone? If it is a clone throw it in the waste can and boy a real pickeit3.

Do have a cable between the board and programmer? If so eliminate the cable and attach the PicKit directly to the board,
 

Thread Starter

pjreijiri

Joined Aug 19, 2015
101
Is this a real PicKit3 or a clone? If it is a clone throw it in the waste can and boy a real pickeit3.

Do have a cable between the board and programmer? If so eliminate the cable and attach the PicKit directly to the board,
It is a real PicKit3. Also I tried it on a different micro controller and it worked fine, so I don’t think it is the problem. And the cable is 3-4” long. Same one that I use every time I want to program a micro controller and it always works
 

Picbuster

Joined Dec 2, 2013
1,047
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?
Pls look at http://ww1.microchip.com/downloads/en/DeviceDoc/40001842D.pdf page 706

I do use mplab 5.01 and xc8 v1.3x / v2.X programing pic18f87k22 / pic18f8722/pic 12f series/ pic 16f series all with same pickit 3 never had a problem. I never used the PIC kit 3 power but board's power supply. (pc is sometimes not producing enough power to feed the whole board)

A few things are important as stated before ' never cap's directly to mclr or the two signal lines. ( always at least 2K resistor in series)
(mclr pin to 2k2 then 10K to VDD and at the resistor junction a100nF to gnd)

Picbuster
 

jpanhalt

Joined Jan 18, 2008
11,087
@pjreijiri
Unfortunately there is some unclear information in this thread. It may lead you off into tangents and wild goose chases. Here are the basic documents from Microchip on which I rely:
2003 Version from Microchip: https://www.elnec.com/sw/30277d.pdf
Update from Microchip: http://microchipdeveloper.com/dtda:icsp-considerations

Some things to note:
1) You do not need to connect your programmer (PK3) directly to the programming pins on your pcb. Microchip sells the PK3 with a flat cable. True, long leads can be a problem. With my first programmer (PicStart Plus) that was designed for off-board programming, i.e., not ICSP, one could use it for ICSP by making jumpers. Those were sensitive to lead length. My ICD3 came from the factory with a short lead (6") and I use it routinely in addition to the PK3 lead of about 8".
2) Do not put resistors as you show.
3) MCLR serves TWO purposes: 1) Programming with Vpp; and 2) Resetting the device. Circuits with capacitors and diodes on MCLR are designed to moderate the resetting behavior. Since you are not using MCLR as a reset at this time, forget about them (I have highlighted them on this snippet from the "update" link above).

upload_2019-4-25_19-24-11.png

If you are not using MCLR for reset and are using HVP, you can set it "off" and ignore all that stuff. In reality, I keep MCLR on during development and just pull it to Vcc (3.3V or 5.0V) with a 10K resistor. Note the use of a diode or 470 ohm resistor to isolate Vpp from the capacitor. If you do not have a capacitor, you do not need either. You are not using PGD and PDC for any other purpose. In brief, there is nothing wrong with the schematic you posted. Of course, we all make mistakes in routing not reflected in the schematic.

Unfortunately, I do not have that chip to play with nor do I have experience with the 18F series, but your symptoms point to a configuration issue that is probably related to LVP,but could be other things (like the wrong device chosen). You have successfully programmed your 16F877, so I suspect the most likely problem is related to LVP or you have done something to the 18F chip to make it appear to be "locked up". If you search on your problem, you will find lots of threads on the Microchip site dealing with similar problems.

Here are just two of those threads related to LVP problems:

https://www.microchip.com/forums/m827846.aspx
https://www.microchip.com/forums/m708340.aspx
 

spinnaker

Joined Oct 29, 2009
7,830
@pjreijiri
Unfortunately there is some unclear information in this thread. It may lead you off into tangents and wild goose chases. Here are the basic documents from Microchip on which I rely:

Some things to note:
1) You do not need to connect your programmer (PK3) directly to the programming pins on your pcb. Microchip sells the PK3 with a flat cable. True, long leads can be a problem. With my first programmer (PicStart Plus) that was designed for off-board programming, i.e., not ICSP, one could use it for ICSP by making jumpers. Those were sensitive to lead length. My ICD3 came from the factory with a short lead (6") and I use it routinely in addition to the PK3 lead of about 8".
2
That is not true. There are several chips that just refuse to work reliably with the flat cable. The microchip forum has a number of posts on this issue. The 18f27J13 and 18f26J53 are just two of the chips that will get flaky if you use the flat cable.
 

jpanhalt

Joined Jan 18, 2008
11,087
That is not true. There are several chips that just refuse to work reliably with the flat cable. The microchip forum has a number of posts on this issue. The 18f27J13 and 18f26J53 are just two of the chips that will get flaky if you use the flat cable.
That issue is not mentioned by Microchip in any datasheet I have seen. In fact, the usual illustration is with a modular cable.

I am familiar with the twists and turns of the Microchip forums. They are like any other forum. A lot of misinformation gets spouted about until a solution is found (if ever). User habits begun while dealing with a problem are often continued regardless of whether that habit actually solved the problem. Please provide links to the discussions you reference. None of us deny that a long cable can be bad. The TS claims his cable is just 3" to 4". It would be informative if those forums had credible information tracing a problem of recognizing the chip to such short cables versus a direct connection.

The PICKit 3 user's manual recommends a cable (https://ww1.microchip.com/downloads/en/DeviceDoc/51795B.pdf , page 19 and following) among the options. Of course direct connection of the PK3 is also an option. The question is whether a direction connection is the root of this TS's problem. As for the 18FxxJ chips, they are different and require a capacitor on the Vcap pin.
 

jpanhalt

Joined Jan 18, 2008
11,087
There are several chips that just refuse to work reliably with the flat cable. The microchip forum has a number of posts on this issue. The 18f27J13 and 18f26J53 are just two of the chips that will get flaky if you use the flat cable.
We are both entitled to an opinion based on our experience; however, you go past that point. You declare my opinion was wrong based on the following:
There are several chips that just refuse to work reliably with the flat cable.
Please give a list of the ones you know so we can all benefit.

The microchip forum has a number of posts on this issue.
Again you refer to "fact" and hint at a citation, but provide nothing more. Please be helpful and fill in the blanks.
 

spinnaker

Joined Oct 29, 2009
7,830
We are both entitled to an opinion based on our experience; however, you go past that point. You declare my opinion was wrong based on the following:

Please give a list of the ones you know so we can all benefit.


Again you refer to "fact" and hint at a citation, but provide nothing more. Please be helpful and fill in the blanks.

I already gave you two. The problem chips seem to be the low voltage ones from what I have seen.

I am done with your blatant obstinance and trolling. Believe whatever you want.
 

Thread Starter

pjreijiri

Joined Aug 19, 2015
101
Hey guys, chillax.
Personally I always used my PK3 with the cable that came with it. I never had a problem. It doesn't mean that you did not have problems with it, @spinnaker.

That is fine.

Back to the scope of this thread, when I plug a power source to it the first time i got some of that ominous smoke. then some features worked but I couldn't program the microcontroller. I have another PCB that is identical, when I try to give it power with an arduino, some of the LEDs turn on and fade and the ON LED on the arduino start fading till it turns off. This usually means that it is drawing more than 500mA.

Could this be a problem?
upload_2019-4-27_15-45-37.png

Could it be that the microcontroller pins are firing HIGH on all pins when it turns on and it is creating a short somewhere?
Also I know I put a 12V in there. I have two circuits in there, one is 5V on which I have my control circuit on and a 12V that I use for all my outputs that run through the mosfets only.
 

jpanhalt

Joined Jan 18, 2008
11,087
Hey guys, chillax.
Personally I always used my PK3 with the cable that came with it. I never had a problem. It doesn't mean that you did not have problems with it, @spinnaker.

That is fine.

Back to the scope of this thread, when I plug a power source to it the first time i got some of that ominous smoke. then some features worked but I couldn't program the microcontroller. I have another PCB that is identical, when I try to give it power with an arduino, some of the LEDs turn on and fade and the ON LED on the arduino start fading till it turns off. This usually means that it is drawing more than 500mA.

Could this be a problem?
View attachment 176129

Could it be that the microcontroller pins are firing HIGH on all pins when it turns on and it is creating a short somewhere?
Also I know I put a 12V in there. I have two circuits in there, one is 5V on which I have my control circuit on and a 12V that I use for all my outputs that run through the mosfets only.
Yes. Is that attached to the pins here?
upload_2019-4-27_17-11-14.png

1) You cannot turn on the top mosfet.
2) Depending on your choice of mosfet, you may not have enough voltage to turn on the bottom one either.
3) But, you may get them into the linear region and create a lot of heat (I^2R).

Remove that entire subcircuit. It will not affect your programming. Smoke? What smoked? What got hot? Any other "unimportant" details you forgot to tell us?
 
Last edited:

jpanhalt

Joined Jan 18, 2008
11,087
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.
Given that new information, maybe your best approach now would be to use a TH variant of that chip or a BOB and try to flash an LED.
 
Top