erase its own code

Discussion in 'Embedded Systems and Microcontrollers' started by bug13, Dec 1, 2014.

  1. bug13

    Thread Starter Well-Known Member

    Feb 13, 2012
    1,208
    38
    Hi guys

    Just wondering, if an MCU (eg PIC) can erase its own code? I mean the code in flash, not the code in eeprom.

    Thanks guys!
     
  2. JohnInTX

    Moderator

    Jun 26, 2012
    2,347
    1,029
    Deliberately or accidentally?

    If a PIC has 'self-write' capability it can erase and re-program flash under program control - also in flash. You wouldn't want to do ALL of the flash..
    Accidental erasures are not unheard of - but the ones I am familiar with are on older chips where transients on MCLR/ exceeded Vpp and initiated a bulk-erase. I don't think is easy to do it with newer chips using ICSP commands to control erase/program.
     
    bug13 likes this.
  3. jpanhalt

    AAC Fanatic!

    Jan 18, 2008
    5,699
    906
    For the PIC series, read about Flash Program Memory in the datasheet. One such chip is the 16F1519. The part about flash memory is Chapter 11.

    John
     
    bug13 likes this.
  4. kubeek

    AAC Fanatic!

    Sep 20, 2005
    4,670
    804
    Some chips for secure applications have a special mechanisms to erase themselves. Some even store the critical parts in battery backed SRAM and cut the power when necessary.
     
    bug13 likes this.
Loading...