• AVR Freaks

Hot!Problem erasing PIC18LF46K42 protection bit with ICD4

Author
BEsmart
Starting Member
  • Total Posts : 37
  • Reward points : 0
  • Joined: 2019/04/26 06:47:36
  • Location: 0
  • Status: offline
2019/10/22 08:45:19 (permalink)
0

Problem erasing PIC18LF46K42 protection bit with ICD4

For a customer project I flashed the PIC and set the write protection bit for copy protection, as I thought it to be.
#pragma config WRTSAF = OFF      // SAF Write protection bit (SAF Write Protected)
Now I have an update for the PIC, but the chip won't erase!
I tried everything to erase memory with both MPLAB X IDE and IPE, but neither worked.
 
Beeing used to AVR, resetting lock bits and erasing a device never was a problem.
Is  this different with PIC or did I do something wrong with the protection bit?
...it is my first time using protection with a PIC.
 
Any help is appreciated, as I have a meeting with my customer tomorrow.... :-|
 
Here is the message from the output:
 
Connecting to MPLAB ICD 4...

Currently loaded versions:
Application version............01.06.08
Boot version...................01.00.00
FPGA version...................01.00.00
Script version.................00.02.77
Script build number............5215401e64
Connecting to MPLAB ICD 4...

Currently loaded versions:
Boot version...................01.00.00
Updating firmware application...
Connecting to MPLAB ICD 4...

Currently loaded versions:
Application version............01.05.18
Boot version...................01.00.00
FPGA version...................01.00.00
Script version.................00.02.77
Script build number............5215401e64
Target voltage detected
Target device PIC18LF46K42 found.
Device Revision Id  = 0x0

Erasing...
Verify failed.  [config mem] 0x300007, expected 0x2f, got 0x25
Failed to erase the device
 
#1

13 Replies Related Threads

    Jim Nickerson
    User 452
    • Total Posts : 6365
    • Reward points : 0
    • Joined: 2003/11/07 12:35:10
    • Location: San Diego, CA
    • Status: offline
    Re: Problem erasing PIC18LF46K42 protection bit with ICD4 2019/10/22 08:54:23 (permalink)
    +1 (1)
    try to only erase the device before re programming.
    Sometimes I find I must use IPE to erase only the device.
    I suspect as power is applied to the device it starts running before the tool begins the erase sequence in  a normal re program
    #2
    NorthGuy
    Super Member
    • Total Posts : 5806
    • Reward points : 0
    • Joined: 2014/02/23 14:23:23
    • Location: Northern Canada
    • Status: offline
    Re: Problem erasing PIC18LF46K42 protection bit with ICD4 2019/10/22 09:06:08 (permalink)
    +1 (1)
    Do you have enough voltage? 2.5V is needed for bulk erase.
    #3
    BEsmart
    Starting Member
    • Total Posts : 37
    • Reward points : 0
    • Joined: 2019/04/26 06:47:36
    • Location: 0
    • Status: offline
    Re: Problem erasing PIC18LF46K42 protection bit with ICD4 2019/10/22 10:39:10 (permalink)
    0
    ...OK, this might be a problem. PIC is running with 2.48V.
    Erasing with ICD3 instead ICD4 now worked. At least the output said so.
    But reprogramming failed.
    There always is verify error. I had this before using ICD3 for programming but not with ICD4. It used to programm without failure. used to.
    Trying to use now ICD4 with IPE, it says the LVP bit must be set...
    I'm totally confused.
    #4
    NorthGuy
    Super Member
    • Total Posts : 5806
    • Reward points : 0
    • Joined: 2014/02/23 14:23:23
    • Location: Northern Canada
    • Status: offline
    Re: Problem erasing PIC18LF46K42 protection bit with ICD4 2019/10/22 11:23:24 (permalink)
    +1 (1)
    There's no way for the programmer to verify erase (short of reading everything back). So, when you only do bulk erase, you don't know if the erase succeeded or not.
     
    Try elevating the voltage to 2.7 and see if this works. When the chip starts drawing current for bulk erase, the voltage may sag for a brief moment below BORV (2.4V nominal) and then the chip will abort the erase. Perhaps, more decoupling and/or bulk capacitors would help to make it work at your 2.48V.
     
    LVP bit has nothing to do with this. If you use LVP for programming, set the LVP bit to ON (because LVP programming will not be able to program it to OFF anyway). If you use HVP, this doesn't matter.
     
    On the second thought, looking at my testing notes, the threshold VDD voltage for successful erase was a little bit higher when you use HVP as compared to LVP. So, try using HVP. This may help with erase.
    #5
    ric
    Super Member
    • Total Posts : 24593
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: Problem erasing PIC18LF46K42 protection bit with ICD4 2019/10/22 14:00:59 (permalink)
    0
    NorthGuy
    ....
    On the second thought, looking at my testing notes, the threshold VDD voltage for successful erase was a little bit higher when you use HVP as compared to LVP. So, try using HVP. This may help with erase.

    Doesn't that indicate that LVP might work better?
     

    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!
    #6
    NorthGuy
    Super Member
    • Total Posts : 5806
    • Reward points : 0
    • Joined: 2014/02/23 14:23:23
    • Location: Northern Canada
    • Status: offline
    Re: Problem erasing PIC18LF46K42 protection bit with ICD4 2019/10/22 14:37:15 (permalink)
    +1 (1)
    ric
    NorthGuy
    ....
    On the second thought, looking at my testing notes, the threshold VDD voltage for successful erase was a little bit higher when you use HVP as compared to LVP. So, try using HVP. This may help with erase.

    Doesn't that indicate that LVP might work better?



    It does. Sorry, my mistake. HVP threshold was lower. It actually says I could program it with HVP at 1.9V. However, I had a regular circut with 10k pull-up and capacitor on MCLR. Perhaps this gave a boost to VDD.
     
    #7
    BEsmart
    Starting Member
    • Total Posts : 37
    • Reward points : 0
    • Joined: 2019/04/26 06:47:36
    • Location: 0
    • Status: offline
    Re: Problem erasing PIC18LF46K42 protection bit with ICD4 2019/10/22 15:55:59 (permalink)
    0
    OK... I soldered a new PIC to the board and programmed it without setting the protection bit. For this time.
    But this could not be the way to go.
    I have a lot of boards with low voltage, down to 1,8V, till now with AVR, and they always worked perfect for running, locking and reprogramming at this voltage.
    When I use a PIC18 LF version, the datasheet says, it also works down to 1.8V, does that mean 1.8V only for running and not for programming or erasing?
    So do I then always have to include some kind of additional connector on my board for a higher voltage while erasing or reprogramming, to get it reliably working?
    This is very important, as not all my boards are as easy to disassemble as this one.
    Is there any kind of information available for the requirements of reliable erase a reprogramming of F and LF verisons?
    Is there a specific process I do have to follow?
    Many Thanks!
     
    #8
    ric
    Super Member
    • Total Posts : 24593
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: Problem erasing PIC18LF46K42 protection bit with ICD4 2019/10/22 16:12:58 (permalink)
    +2 (2)
    The product page for the PIC18LF46K42 is at
    https://www.microchip.com/wwwproducts/en/PIC18F46K42
    which links to the programming specification at
    http://ww1.microchip.com/downloads/en/DeviceDoc/40001886B.pdf
    Page 24 spells out that bulk erase requires 2.4V. You need bulk erase to erase protection bits.
     

    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!
    #9
    NorthGuy
    Super Member
    • Total Posts : 5806
    • Reward points : 0
    • Joined: 2014/02/23 14:23:23
    • Location: Northern Canada
    • Status: offline
    Re: Problem erasing PIC18LF46K42 protection bit with ICD4 2019/10/22 17:08:41 (permalink)
    +2 (2)
    BEsmart
    When I use a PIC18 LF version, the datasheet says, it also works down to 1.8V, does that mean 1.8V only for running and not for programming or erasing?
    So do I then always have to include some kind of additional connector on my board for a higher voltage while erasing or reprogramming, to get it reliably working?



    ric is right. You cannot remove protection if voltage is too low because the only way to remove protection is bulk erase. This is true for the majority of PICs. Nothing you can do about this.
     
    If the PIC is not protected, you can program it at any voltage. However, to program at lower voltages you need specific programming algorithms which avoid bulk erase and erase page-by-page instead. I don't know if Microchip programmers use such algorithms.
     
    In addition, the Errata say this PIC will not run at 1.8V at all, and in my tests it didn't (I tested PIC18LF26K42). May be new silicon revision will fix this.
     
    #10
    BEsmart
    Starting Member
    • Total Posts : 37
    • Reward points : 0
    • Joined: 2019/04/26 06:47:36
    • Location: 0
    • Status: offline
    Re: Problem erasing PIC18LF46K42 protection bit with ICD4 2019/10/23 06:51:57 (permalink)
    0
    Thanks!
    Programming specification says "~2.4V" , it is just about  2.4V . So maybe better to stay away more from this limit.
    For the next low voltage design, wouldn't it make sense, to make the layout in a way to supply higher voltage from ICD via Vdd_TGT -line while programming / erasing?
    #11
    NorthGuy
    Super Member
    • Total Posts : 5806
    • Reward points : 0
    • Joined: 2014/02/23 14:23:23
    • Location: Northern Canada
    • Status: offline
    Re: Problem erasing PIC18LF46K42 protection bit with ICD4 2019/10/23 12:42:53 (permalink)
    +1 (1)
    BEsmart
    For the next low voltage design, wouldn't it make sense, to make the layout in a way to supply higher voltage from ICD via Vdd_TGT -line while programming / erasing?



    If your board can tolerate higher VDD then using higher VDD during programming is the best solution.
    #12
    ric
    Super Member
    • Total Posts : 24593
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: Problem erasing PIC18LF46K42 protection bit with ICD4 2019/10/23 13:20:04 (permalink)
    +2 (2)
    BEsmart
    Thanks!
    Programming specification says "~2.4V" , it is just about  2.4V .



    That is an absolute minimum.
    If your supply is 2.4V with 0.1v noise, you are going below the minimum.
     

    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!
    #13
    BEsmart
    Starting Member
    • Total Posts : 37
    • Reward points : 0
    • Joined: 2019/04/26 06:47:36
    • Location: 0
    • Status: offline
    Re: Problem erasing PIC18LF46K42 protection bit with ICD4 2019/10/24 11:06:50 (permalink)
    0
    You are right.
    I did some more test with the not erasable PIC, I thought to be dead.
    A Vdd above 2.6V made it work correct again. Erasing and programming is no problem.
    I learned a lot....
    #14
    Jump to:
    © 2019 APG vNext Commercial Version 4.5