2022-06-04 01:06 AM
Hello dear all,
On STM32G0B0 I try to performe a Flash programming fast after erasing 2 pages on bank 2.
1�?⃣
Erase code :
uint32_t PageError;
FLASH_EraseInitTypeDef tEraseInit;
tEraseInit.TypeErase = FLASH_TYPEERASE_PAGES;
tEraseInit.Banks = FLASH_BANK_2;
tEraseInit.Page = 0;
tEraseInit.NbPages = 2;
HAL_FLASH_Unlock();
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_OPTVERR);
HAL_FLASHEx_Erase(&tEraseInit, &PageError);
HAL_FLASH_Lock();
✔�? This is working well. Both pages are erased and HAL_FLASHEx_Erase() return HAL_OK.
Memory content before erase operation :
Memory after erase operation:
2�?⃣
Immediatly after, I try to program in fast mode in first erased page :
HAL_FLASH_Unlock();
HAL_FLASH_Program(FLASH_TYPEPROGRAM_FAST, 0x08040000, (uint32_t)&buff_test)
HAL_FLASH_Lock();
�?��? This does not work. It return HAL_ERROR and set pFlash.ErrorCode = 0x2A0 : (FASTERR | PGSERR | PGAERR).
Memory content after programming first erased page :
3�?⃣
However if I try to program in fast mode the last erased page.
HAL_FLASH_Unlock();
HAL_FLASH_Program(FLASH_TYPEPROGRAM_FAST, 0x08040800, (uint32_t)&buff_test)
HAL_FLASH_Lock();
✔�? It's work !
Memory content after programming last erased page :
�?�? Could you please help to know why programming fast in NON last erased page doesn't work ?
Best regards.