SNIU028D February 2016 – September 2020 UCD3138 , UCD3138064 , UCD3138064A , UCD3138128 , UCD3138A , UCD3138A64
The code for erasing flash is very similar, except instead of writing to the program flash word, it actually writes to the program flash control register and does a mass erase.
The C calling function is very similar. Only the labels for the code which is copied change.
Here is the code to clear the program flash:
void clear_program_flash(void)
{
DecRegs.PFLASHCTRL.bit.MASS_ERASE = 1; //erase it all
while(DecRegs.PFLASHCTRL.bit.BUSY != 0)
{
; //do nothing while it programs
}
return;
}