erase its own code

Thread Starter

bug13

Joined Feb 13, 2012
2,002
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!
 

JohnInTX

Joined Jun 26, 2012
4,787
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.
 

jpanhalt

Joined Jan 18, 2008
11,087
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.

Source=PIC1519 datasheet
The Flash program memory is readable and writable during normal operation over the full VDD range.
Program memory is indirectly addressed using Special Function Registers (SFRs).
John
 

kubeek

Joined Sep 20, 2005
5,794
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.
 
Top