STM32F031G8, getting a hard fault in any attempt at eeprom emulation, specifically on page erase.
Howdy,
I'm ending up in the hard fault handler on any attempt at page erase. Using the function from stm32g0xx_hal_flash_ex.c
void FLASH_PageErase(uint32_t Banks, uint32_t Page)
{
volatile uint32_t tmp;
/* Check the parameters */
assert_param(IS_FLASH_BANK(Banks));
assert_param(IS_FLASH_PAGE(Page));
/* Get configuration register, then clear page number */
tmp = (FLASH->CR & ~FLASH_CR_PNB);
#if defined(FLASH_DBANK_SUPPORT)
/* Check if page has to be erased in bank 1 or 2 */
if(Banks != FLASH_BANK_1)
{
tmp |= FLASH_CR_BKER;
}
else
{
tmp &= ~FLASH_CR_BKER;
}
#endif
/* Set page number, Page Erase bit & Start bit */
FLASH->CR = (tmp | (FLASH_CR_STRT | (Page << FLASH_CR_PNB_Pos) | FLASH_CR_PER));
}There on line 25, I crash when writing to FLASH->CR; I've confirmed that just setting the FLASH_CR_PER bit causes the hard fault.
I tried using ST's provided eeprom emulation firmware as well, with the same result in the same function. Any ideas what is going on here? Or maybe some simple verified code to store and retrieve a value from flash?
Thanks in advance.
