I'm using a K20 (MK20DX128VLK7) processor.
Occasionally when I try to erase a block of the program flash I get an FTFL_FSTAT result with the MGSTAT0 bit set.
The block of flash still seems to have been erased properly.
It's very simple code:
FTFL_FCCOB0 = 0x09;
FTFL_FCCOB1 = (addr >> 16) & 0xff;
FTFL_FCCOB1 = (addr >> 8) & 0xff;
FTFL_FCCOB1 = (addr) & 0xff;
FTFL_FSTAT |= FTFL_FSTAT_CCIF_MASK;
while (!(FTFL_FSTAT & FTFL_FSTAT_CCIF_MASK)) ;
Any ideas on how to avoid this error or detect what is causing it?