cancel
Showing results for 
Search instead for 
Did you mean: 

STM32G0 Flash program fast on non last erased page

MTE_MMO
Associate

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 :

0693W00000NrCuTQAV.pngMemory after erase operation:

0693W00000NrCuYQAV.png 

 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 :

0693W00000NrCusQAF.png 

 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 :

0693W00000NrCvRQAV.png 

�?�? Could you please help to know why programming fast in NON last erased page doesn't work ?

Best regards.

0 REPLIES 0