• AVR Freaks

Hot!Programming PIC causes Device ID to become unrecognisable

Author
Jetroid
New Member
  • Total Posts : 5
  • Reward points : 0
  • Joined: 2016/02/13 13:06:46
  • Location: 0
  • Status: offline
2019/12/05 08:51:38 (permalink)
0

Programming PIC causes Device ID to become unrecognisable

Hi All,
 
I'm working with the PIC16F88, and have used it in several other projects in the past. I can therefore confirm that there is no problem with my hardware configuration as I don't experience any problems when I try to program my other projects.
 
My most recent code commit causes the PIC to gain an unrecognisable Device ID when programmed. 

Steps:
Press Make and Program Device Main Project
Device ID recognised, Device Erased, Programming, program/verify complete, etc
Press Make and Program Device Main Project a second time (Even without removing the PIC from the burner)
"Target Device ID (0x0) is an Invalid Device ID. Please check your connections to the Target Device."
If I press "OK" to continue, I see (regular output followed by):
Address: 0 Expected Value: 2a1b Received Value: 0
Failed to program device
 
If I try to reprogram one of these 'killed' PIC with another 'known good' project, then I experience the same problems.
 
Strangely, my code seems to burn onto the device correctly, as these 'killed' PICs continue to function in my application.
 
I'm programming the PICs with assembly and a genuine PICkit 3, am using ~800 of my 4K of program memory, am using all of my 256 EEPROM bytes. HVP is being used and the PIC in the programming jig is powered from a (tested good) external 5V source. Configuration words are 2D58 / 3FFC.
 
I'm kind of flummoxed by this, and to date I've rendered 6 PIC16F88s non-functional by trying to write to them after commenting some sections of code out to try to narrow down the problem. I only have a few of these devices left now and I don't want to ruin more (and run out). I also don't want to revert the commit as I need the functionality it implements (and I've seen it working, because, as stated previously, the chip still functions, I just can't read it/burn it anymore). 

Does anyone have any idea what I'm doing wrong or what is going wrong here?
 
Jet Holt
post edited by Jetroid - 2019/12/05 09:27:08
#1

19 Replies Related Threads

    NKurzman
    A Guy on the Net
    • Total Posts : 18255
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: offline
    Re: Programming PIC causes Device ID to become unrecognisable 2019/12/05 09:38:39 (permalink)
    0 (2)
    Are you Disabling MCLR? in the Config Bits?
    LVP or HVP in the config bits?  And the Programmer?
    #2
    jack@kksound
    code tags!
    • Total Posts : 3224
    • Reward points : 0
    • Joined: 2014/05/14 10:03:19
    • Location: 0
    • Status: offline
    Re: Programming PIC causes Device ID to become unrecognisable 2019/12/05 09:41:23 (permalink)
    +1 (1)
    Some of the older pics had an issue with programming if the MCLR was disabled (as you have) and PORTB was set to output mode too quickly out of reset, a delay was needed before changing the direction of the port pins to allow the entry into programming mode correctly (I think I have this right, been a while).
    #3
    Jetroid
    New Member
    • Total Posts : 5
    • Reward points : 0
    • Joined: 2016/02/13 13:06:46
    • Location: 0
    • Status: offline
    Re: Programming PIC causes Device ID to become unrecognisable 2019/12/05 09:47:02 (permalink)
    0
    @NKurzman
     
    As mentioned, my Configuration words are 2D58 / 3FFC.
     
    FOSC : INTOSCIO
    WDTE : OFF
    PWRTE : OFF
    MCLRE : OFF
    BOREN : ON
    LVP : OFF
    CPD : OFF
    WRT : 256
    CCPMX : RB3
    CP : OFF
    FCMEN : OFF
    IESO : OFF

    @jack@kksound:
     
    That's interesting, I hadn't heard about that. Indeed, PORTB is mostly set to digital outputs for me. Where can I read more about this phenomenon, as a cursory google search isn't leading me to anything about that? What kind of delay is needed?   
     
    #4
    Jetroid
    New Member
    • Total Posts : 5
    • Reward points : 0
    • Joined: 2016/02/13 13:06:46
    • Location: 0
    • Status: offline
    Re: Programming PIC causes Device ID to become unrecognisable 2019/12/05 10:04:50 (permalink)
    0
    @jack@kksound
     
    Yep, that seems to be the problem. I added a 100ms delay before my code and now I don't see a problem.
     
    Is there any way to recover my chips that have the old code?
     
    Regards,
    Jet Holt. 
    #5
    jack@kksound
    code tags!
    • Total Posts : 3224
    • Reward points : 0
    • Joined: 2014/05/14 10:03:19
    • Location: 0
    • Status: offline
    Re: Programming PIC causes Device ID to become unrecognisable 2019/12/05 10:06:51 (permalink)
    0
    Search this forum, should be somewhere. A long enough delay to allow the pickit3 to perform the programming setup steps. I am not sure what that would be however maybe someone else here with more specific knowledge will offer it up.
    #6
    jack@kksound
    code tags!
    • Total Posts : 3224
    • Reward points : 0
    • Joined: 2014/05/14 10:03:19
    • Location: 0
    • Status: offline
    Re: Programming PIC causes Device ID to become unrecognisable 2019/12/05 10:08:05 (permalink)
    +3 (3)
    I understand there is a setting in the pickit3 that may help, something about "Vpp first" program mode or like that.
     EDIT: I may have that setting name wrong, I can't look at it right now.
    post edited by jack@kksound - 2019/12/05 10:11:15
    #7
    ric
    Super Member
    • Total Posts : 25562
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Programming PIC causes Device ID to become unrecognisable 2019/12/05 12:22:33 (permalink)
    0
    Yes, it is "Vpp before Vdd" mode that is required.
    The OP has not mentioned if they are using MPLABX or MPLAB8 to do the programming.
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #8
    Jetroid
    New Member
    • Total Posts : 5
    • Reward points : 0
    • Joined: 2016/02/13 13:06:46
    • Location: 0
    • Status: offline
    Re: Programming PIC causes Device ID to become unrecognisable 2019/12/05 12:38:41 (permalink)
    0
    @ric,
    I'm using MPLABX v5.05 with a PICkit 3 on Linux.
    I don't see a "Vpp before Vdd" option in my project properties. Does it require using the PICkit 3 to power the target?
    post edited by Jetroid - 2019/12/05 12:50:07
    #9
    ric
    Super Member
    • Total Posts : 25562
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Programming PIC causes Device ID to become unrecognisable 2019/12/05 14:19:55 (permalink)
    0
    Jetroid
    ...
     Does it require using the PICkit 3 to power the target?

    Yes.
    The PK3 must be controlling both to be able to raise Vpp before Vdd.
    If you go into your project properties, select the PK3, and select "Program options" from the dropdown, the last option should be "Programming method", and the two options are:
    • "Apply Vpp before Vdd (Recommended)"
    • "Apply Vdd before Vpp"

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #10
    ric
    Super Member
    • Total Posts : 25562
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Programming PIC causes Device ID to become unrecognisable 2019/12/05 14:20:55 (permalink)
    0
    You may find that just enabling the PK3 to power the PIC is all you need to be able to reprogram the chips.
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #11
    EverGreen_28
    New Member
    • Total Posts : 28
    • Reward points : 0
    • Joined: 2018/08/14 11:09:01
    • Location: Argentina
    • Status: offline
    Re: Programming PIC causes Device ID to become unrecognisable 2019/12/05 14:48:27 (permalink)
    0
    In version 5.05 and 5.10 has no option to "VPP before VDD"
     
    In version 5.20 (actually i used) the option exist.
     
    I recommend to update to at least 5.20
     
    post edited by EverGreen_28 - 2019/12/05 14:49:54
    #12
    LucaAg
    New Member
    • Total Posts : 3
    • Reward points : 0
    • Joined: 2019/12/05 05:26:57
    • Location: 0
    • Status: offline
    Re: Programming PIC causes Device ID to become unrecognisable 2019/12/05 14:58:49 (permalink)
    0
    Hi Jet,
     
    I experimented the same problem, more than once, when sometimes I made wrong GND reference connection.
    In example I was debugging an application, supplying the target board with an isolated transformer, and than I conncted the scope probe.
     
    Probably due to a pretty high current flowing on the EARTH connection, the PIC broke and I was no more able to program it.
    So, my advise,  if you're debugging the board, avoid to connect it to any other electrical device, if not fully isolated.
     
    Rgds, Luca   
     
     
    #13
    hudejun
    Electrical engineer
    • Total Posts : 15
    • Reward points : 0
    • Joined: 2019/12/05 08:48:06
    • Location: 0
    • Status: offline
    Re: Programming PIC causes Device ID to become unrecognisable 2019/12/05 16:49:52 (permalink)
    0
    Are you using RB6 and RB7 as output pin?
    Then, it should be set to input for a few milliseconds at the start of the power.
    If firmware control output(RB6&7) without delay at the first moment, it will be bricked continuously.
    #14
    Jetroid
    New Member
    • Total Posts : 5
    • Reward points : 0
    • Joined: 2016/02/13 13:06:46
    • Location: 0
    • Status: offline
    Re: Programming PIC causes Device ID to become unrecognisable 2019/12/05 20:13:56 (permalink)
    0
    I just upgraded to 5.30, but I still don't see 'VPP before VDD' in my project properties.
     
     

    Attached Image(s)

    #15
    ric
    Super Member
    • Total Posts : 25562
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Programming PIC causes Device ID to become unrecognisable 2019/12/05 20:33:26 (permalink)
    0
    Same here.
    I do see it if I select other model PICs, but it disappears if I select PIC16F88.
     
    If you could somehow force RB6 and RB7 low when MCLR/Vpp was low, but release them as soon as it was raised, you MIGHT be able to erase the PIC, which would get you out of trouble.
    I'm not sure how you'd do that without a lot of external circuitry though.
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #16
    NorthGuy
    Super Member
    • Total Posts : 5917
    • Reward points : 0
    • Joined: 2014/02/23 14:23:23
    • Location: Northern Canada
    • Status: online
    Re: Programming PIC causes Device ID to become unrecognisable 2019/12/05 21:00:11 (permalink)
    +1 (1)
    Remove power from your PIC.
     
    Build a circuit which powers your PIC at 5V when MCLR goes to 13V - the simplest way is an 8 V zener between MCLR and VDD, or a chain of diodes.
     
    Configure PICkit3 not to provide power, disconnect VDD pin of the PICkit3 connecter from your PIC and connect it to 5V.
     
    Then erase.
    #17
    Ian.M
    Super Member
    • Total Posts : 13268
    • Reward points : 0
    • Joined: 2009/07/23 07:02:40
    • Location: UK
    • Status: offline
    Re: Programming PIC causes Device ID to become unrecognisable 2019/12/06 01:37:36 (permalink)
    0
    The PICkit 3 Vpp/MCLR output cant supply much current and overloading it can kill your PICkit 3.
     
    A better approach to hacking Vpp first mode in hardware is to run the target Vdd supply through a N-MOSFET from external 5v, with its gate driven by Vpp. You may need a 1K resistor in series with the gate to reduce the loading on Vpp during transitions.  You may also need a pull-down resistor on target Vdd.  You'll still need the programmer Vdd connected to 5V so it 'knows' it can't control Vdd, as NorthGuy mentioned above.
     
    However the old PICkit 3 standalone software v3.10 supports VPP first mode, and that would be my first choice for salvaging 'locked out' parts
    post edited by Ian.M - 2019/12/06 08:03:53

    --
    NEW USERS: Posting images, links and code - workaround for restrictions.
    I also support http://picforum.ric323.com because this forum is sometimes too broken to use!
    #18
    oliverb
    Super Member
    • Total Posts : 264
    • Reward points : 0
    • Joined: 2009/02/16 13:12:38
    • Location: 0
    • Status: offline
    Re: Programming PIC causes Device ID to become unrecognisable 2019/12/06 01:46:04 (permalink)
    0
    You have brown-out reset enabled. Is it possible to try erasing with a VDD below the brown-out threshold, so the program doesn't start? It looks as if the threshold is 4V.
    Even if it corrupts you should'd then be able to re-program at 5V.
    #19
    atferrari
    Super Member
    • Total Posts : 1386
    • Reward points : 0
    • Joined: 2004/07/08 13:09:24
    • Location: Buenos Aires - Argentina
    • Status: offline
    Re: Programming PIC causes Device ID to become unrecognisable 2019/12/06 06:23:09 (permalink)
    0
    What about with PICkit4?
     
    Should I care of something? Just one week using it with good results so far. No previous experience with any PICkitx-

    Agustín Tomás

    In theory, there is no difference between theory and practice. In practice, however, there is.

    http://cablemodem.fibertel.com.ar/atferrari/
    #20
    Jump to:
    © 2020 APG vNext Commercial Version 4.5