stm32l4/flashpage: fix page erase

- The PNB in FLASH_CR wasn't cleared before every erase operation
  and the new value was just stacked on top. After a couple of erase
  the PNB written was overlapping with old ones failing to erase the
  correct page.
This commit is contained in:
francisco 2019-07-03 09:30:03 +02:00
parent 135ad3817b
commit 26a8013502

View File

@ -111,6 +111,7 @@ static void _erase_page(void *page_addr)
} }
pn = (uint8_t)page; pn = (uint8_t)page;
#endif #endif
CNTRL_REG &= ~FLASH_CR_PNB;
CNTRL_REG |= (uint32_t)(pn << FLASH_CR_PNB_Pos); CNTRL_REG |= (uint32_t)(pn << FLASH_CR_PNB_Pos);
CNTRL_REG |= FLASH_CR_STRT; CNTRL_REG |= FLASH_CR_STRT;
#else /* CPU_FAM_STM32F0 || CPU_FAM_STM32F1 */ #else /* CPU_FAM_STM32F0 || CPU_FAM_STM32F1 */