2014-07-09 02:55 AM
Hi, I'm running the example code to try to program the flash memory. This starts:
void WriteFlash(void){ /*!< At this stage the microcontroller clock setting is already configured, this is done through SystemInit() function which is called from startup file (startup_stm32f4xx.s) before to branch to application main. To reconfigure the default setting of SystemInit() function, refer to system_stm32f4xx.c file */ /* Unlock the Flash to enable the flash control register access *************/ FLASH_Unlock(); /* Erase the user Flash area (area defined by FLASH_USER_START_ADDR and FLASH_USER_END_ADDR) ***********//* Clear pending flags (if any) */ FLASH_ClearFlag(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR | FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR|FLASH_FLAG_PGSERR); ............. etc................ Then it erases the flash:if (FLASH_EraseSector(i, VoltageRange_3) != FLASH_COMPLETE) ..... But when I step into this, it jumps out to a hard fault on this line:/* if the erase operation is completed, disable the SER Bit */ FLASH->CR &= (~FLASH_CR_SER);Does anyone know what the hard fault is and how to overcome it?Thanks2014-07-09 05:58 AM
2014-07-09 06:22 AM
Solved it, I did not think I was, but I was erasing the code that was running. derrrrrr.
That tends to rain on the parade a bit. I'd also watch out for what the ART has cached.