Question
PEP in FLASH_0.MCR cleared automatically while EHV=0
Hi,
The PEP flag (of FLASH_0.MCR) should be set when I try to write to protected block of flash.
I observe, that this flag is cleared automatically at the moment of clearing EHV flag.
Is it intended and should be written in RM? Or do I do something wrong?
uint8_t DoFlashing (void ) {
// clear potential error flags
FLASH_0.MCR.R |= FLASH_0_MCR_ERROR_FLAGS;
// start erasing/program
FLASH_0.MCR.B.EHV = 1; // here PEP gets 1 because flash is LOCKED
// active wait to be finished
while (!FLASH_0.MCR.B.DONE) {}
FLASH_0.MCR.B.EHV = 0; // here PEP returns to 0
FLASH_0.MCR.B.ERS = 0;
FLASH_0.MCR.B.PGM = 0;
if (FLASH_0.MCR.B.PEP) {
// DOES NOT WORK !!!
return FALSE;
}
return FLASH_0.MCR.B.PEG;
}Best,
Yannek
