Author Topic: PIC18: Cannot program, Invalid Device ID, Circuitry on MCLR?  (Read 8633 times)

0 Members and 1 Guest are viewing this topic.

Offline smoothVTerTopic starter

  • Regular Contributor
  • *
  • Posts: 145
  • Country: us
PIC18: Cannot program, Invalid Device ID, Circuitry on MCLR?
« on: January 11, 2017, 02:47:59 pm »
Hello:

I cannot program a PIC18 in-circuit on the target device board.    The messages from MPLAB X read:

Quote
Connecting to MPLAB ICD 3...

Currently loaded firmware on ICD 3
Firmware Suite Version.....01.44.26
Firmware type..............PIC18FJ

Target voltage detected
Target Device ID (0x0) is an Invalid Device ID. Please check your connections to the Target Device.

Device Erased...

Programming...

The following memory area(s) will be programmed:
program memory: start address = 0x0, end address = 0x37f
configuration memory
program memory
Address: 0 Expected Value: 54 Received Value: 0
Failed to program device


I have inherited this design from another engineer who has since left the country.  I've simplified the schematic below to only the relevant sections:



  • Using MPLAB X, ICD3, with a PIC18F46J50.  I have all updated drivers and new install of MPLAB.
  • In firmware development phase, I've been using a Explorer 8 development board with a plug in module for this exact same processor except it is in the leaded version;  programming works flawlessly from day one on the Explorer 8 dev board.    On the product board, programming fails. 
  • I have no idea what the intention of D1A/B, R6, C3 is.   Has anyone ever seen this particular arrangement on circuitry on MCLR and know its intention? Personally I have never seen this arrangement before, but I am fairly certain the prior engineer knew what they were doing;  they just did not document the intention behind this before.   Could D1A/B, R6, C3 be affecting the programming of my in-circuit device? 
  • I have quadruple-checked my programming connections  PGD, PGC, VPP/MCLR, VDD, GND   They are all good. 
  • J5/6 and J16/17 are external pushbutton switches on portB;  no external pullups, the intention is to use the weak internal pullups of the PIC for these pins.  These two pins are shared with PGD and PGC.  Could this be a source of the programming problem?   
 

Offline DTJ

  • Frequent Contributor
  • **
  • Posts: 997
  • Country: au
Re: PIC18: Cannot program, Invalid Device ID, Circuitry on MCLR?
« Reply #1 on: January 11, 2017, 02:57:47 pm »
To be certain try removing the two 100R resistors, remove D1 and test.
 

Offline wraper

  • Supporter
  • ****
  • Posts: 16860
  • Country: lv
Re: PIC18: Cannot program, Invalid Device ID, Circuitry on MCLR?
« Reply #2 on: January 11, 2017, 03:21:47 pm »
C1 will fight pulling down of MLCR. Replace D1B with 4.7k resistor and she'll be fine.
 

Offline smoothVTerTopic starter

  • Regular Contributor
  • *
  • Posts: 145
  • Country: us
Re: PIC18: Cannot program, Invalid Device ID, Circuitry on MCLR?
« Reply #3 on: January 11, 2017, 03:43:01 pm »
Unfortunately I cannot only remove D1B ... D1A/B are in the same package.  I would have to remove both D1A and D1B at the same time, but since I am not sure what the function of D1A is, I do not know if they are providing some sort of protection or isolation which if removed would damage the PIC in-circuit.   Any idea?

 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12856
Re: PIC18: Cannot program, Invalid Device ID, Circuitry on MCLR?
« Reply #4 on: January 11, 2017, 04:03:28 pm »
The 'reset circuit' components C3, D1A,D1B serve no useful function as there is an internal weak pullup on /MCLR, and D1B prevents C6 holding /MCLR low while its charging.   Disconnect it and try a simple 10K pullup on /MCLR.

See: http://www.microchip.com/forums/m692754.aspx

Other causes of programming problems can include excessive load on Vdd if the programmer is supplying power, or poor decoupling - especially Vcore or Vcap.  The datasheet generally specifies a ceramic cap. Tantalums will usually also work, but Aluminium electrolytics tend to have excessive ESR and poor high frequency performance.
 

Offline wraper

  • Supporter
  • ****
  • Posts: 16860
  • Country: lv
Re: PIC18: Cannot program, Invalid Device ID, Circuitry on MCLR?
« Reply #5 on: January 11, 2017, 04:07:59 pm »
I do not know if they are providing some sort of protection or isolation which if removed would damage the PIC in-circuit.   Any idea?
D1A is to discharge the cap when Vcc goes down. That is to prevent reset problems if you reapply the power fast enough, and cap still stays charged. D1A is not required at all, and, frankly, all of that circuit either. You could put different diode in sot-23 which has only one diode inside and bodge a resistor. But frankly, I really doubt previous engineer was fully understanding what he was doing.

BTW this circuit does not provide any protection of the MLCR pin whatsoever.
 
The following users thanked this post: smoothVTer

Offline wraper

  • Supporter
  • ****
  • Posts: 16860
  • Country: lv
Re: PIC18: Cannot program, Invalid Device ID, Circuitry on MCLR?
« Reply #6 on: January 11, 2017, 04:14:30 pm »
The 'reset circuit' components C3, D1A,D1B serve no useful function as there is an internal weak pullup on /MCLR
Yep, the only thing it does, messes up with programming. If there was a resistor or just direct connection instead of D1B, it would at least do an external reset.
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12856
Re: PIC18: Cannot program, Invalid Device ID, Circuitry on MCLR?
« Reply #7 on: January 11, 2017, 04:21:49 pm »
A 5.6K resistor instead of D1B would work as all Microchip programmers and debuggers since the ICD2 and PICkit 2 are specced to drive a load of up to 5K on /MCLR.  You can usually get away with 4K7 isolation resistors - lower is problematic.   A direct connection is also likely to be problematic as excessive capacitance on /MCLR can cause the programmer to report a Vpp error or can cause programming mode entry problems resulting in various other errors.
 

Offline smoothVTerTopic starter

  • Regular Contributor
  • *
  • Posts: 145
  • Country: us
Re: PIC18: Cannot program, Invalid Device ID, Circuitry on MCLR?
« Reply #8 on: January 11, 2017, 06:25:57 pm »
Hello everybody, thank you once again for your timely and productive help.   I keep saying this but I wish I could buy you all a beer.

(1)   First I removed the entire D1, C3, and R6 circuitry.   From your analysis as well as what I've read on Microchip's site, I agree that this could most likely cause programming issues.  I removed D1/C3/R6   and added in place a 10k pullup from VDD to MCLR.  I tried programming again, and again failed with the same message.    :palm:

(2)  I moved on to removing all other possible sources of interference:    R5 and R8.   R5 & R8 share  the  PGD  and PGC  pins and go straight into the high side of separate common-mode chokes, which are connected to N.O.  momentary switches.   I believe the prior engineer was looking to minimize EMI interference into the button inputs, remove some common mode noise, or slow down edge rates.   Whatever the reason,  once I removed R5 & R8, I was able to program and communicate with my PIC18 in-circuit successfully.

Even though J5 and J17 are left open floating ( giving no DC path to ground ),  it seems the nature of the common-mode choke will still load down whatever is attached (? this is only my initial supposition ) to the other coupled side.       What do you think?  How does this common-mode choke ( with no DC path ) affect the clock/data lines?

Plan moving forward:    I am going to try better isolating the chokes from PGC/PGM  using increased values of  series resistors in place of R5 / R8  and see if I can successfully program in circuit once I solder in, say, 500 or 1k ohm in lieu.    I will report back if I am successful or not. 



 

Online PA0PBZ

  • Super Contributor
  • ***
  • Posts: 5127
  • Country: nl
Re: PIC18: Cannot program, Invalid Device ID, Circuitry on MCLR?
« Reply #9 on: January 11, 2017, 06:40:26 pm »
Even though J5 and J17 are left open floating ( giving no DC path to ground ),  it seems the nature of the common-mode choke will still load down whatever is attached (? this is only my initial supposition ) to the other coupled side.       What do you think?  How does this common-mode choke ( with no DC path ) affect the clock/data lines?

Two wires closely wound together leaving the other end open will create a nice capacitor.
Keyboard error: Press F1 to continue.
 
The following users thanked this post: smoothVTer

Offline smoothVTerTopic starter

  • Regular Contributor
  • *
  • Posts: 145
  • Country: us
Re: PIC18: Cannot program, Invalid Device ID, Circuitry on MCLR?
« Reply #10 on: January 11, 2017, 06:57:08 pm »
SOLVED

I changed R5 & R8  from    100 ohms  to   470 ohms.    This seems to have isolated the CM chokes enough to allow correct PIC programming.  I'll keep a weary eye out for future programming errors and make a note in my reports in case an issue like this sneaks up again on someone else.

About the note for the non-standard ICSP port pinout:   I am aware of this and quadruple-checked my connections to and from the programmer, had to do some creative micro wire soldering to match what is on the PCB.




 

Offline jaromir

  • Supporter
  • ****
  • Posts: 338
  • Country: sk
Re: PIC18: Cannot program, Invalid Device ID, Circuitry on MCLR?
« Reply #11 on: January 11, 2017, 07:29:59 pm »
The "non-standard" ICSP pin layout is actually somehow better than "standard" where PGC and PGD are on adjacent lines, making it more susceptible to crosstalk between the lines, especially on longer lines from programmer - see here http://www.embedinc.com/picprg/icsp.htm - I've been bitten by this problem in past.
 
The following users thanked this post: smoothVTer

Offline wraper

  • Supporter
  • ****
  • Posts: 16860
  • Country: lv
Re: PIC18: Cannot program, Invalid Device ID, Circuitry on MCLR?
« Reply #12 on: January 12, 2017, 01:42:30 am »
I moved on to removing all other possible sources of interference:    R5 and R8.   R5 & R8 share  the  PGD  and PGC  pins and go straight into the high side of separate common-mode chokes, which are connected to N.O.  momentary switches.   I believe the prior engineer was looking to minimize EMI interference into the button inputs, remove some common mode noise, or slow down edge rates.   Whatever the reason,  once I removed R5 & R8, I was able to program and communicate with my PIC18 in-circuit successfully.
My guts tells me that previous engineer is an idiot.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf