AnsweredAssumed Answered

STM2F4xx (ST3240G) can't clear FLASH error flags

Question asked by Jack Peacock on Jun 1, 2012
Latest reply on Sep 24, 2014 by christopher.ralph
I am trying to erase and program a 16KB sector (sector 2) in the STM32F405 (rev A) on the ST3240G eval board.  The problem is that two error flags (PGSERR and PGPERR) are set and cannot be cleared.

Soon after a reset, still running at 16MHz on HSI, no PLL, and before any attempt to erase or write to flash I use this sequence to clear the error flags in the status register:
{           // clear flash error
    FLASH_Unlock(); // Unlock the Flash Program Erase controller
        FLASH_FLAG_OPERR | FLASH_FLAG_EOP); // clear error status
    test = FLASH->SR;               // DEBUG
    FLASH_Lock();   // Lock the Flash Program Erase controller
When I step through the code I see the FLASH->SR register set to 0x0000 00c0 before and after the call to reset the flags.

Is there a reason these error flags are set immediately after a reset?  The flash programming guide says the default on reset is 0x0000 0000.
  Jack Peacock