2022-04-13 02:47 AM
Hello folk, i hope you fine, i am using the STM32L072, i need erase FLASH memory from 0x08008000 up to the end, i read in the datasheet that every sector has 4Kb and every page has 128 bytes, i have the following:
FLASH_EraseInitTypeDef borrat;
borrat.NbPages = 1;
borrat.PageAddress = 0x8008000; //flashAddr;
borrat.TypeErase = FLASH_TYPEERASE_PAGES;
uint32_t pagE;
HAL_FLASH_Unlock();
// HAL_FLASHEx_Erase(&borrat, &pagE);
HAL_FLASH_Lock();
In this code it erase just a page from 0x8008000, is that true? so i don't understand how to erase all pages from start position up to the end, can someone helps me?¿
Thanks a lot!
Solved! Go to Solution.
2022-04-13 05:02 AM
Well, if you specify only one page to delete, only one page will be deleted.
So you should calculate the number of pages to be deleted and then specify that at NbPages.
Does it answer your question?
Regards
/Peter
2022-04-13 04:58 AM
NbPages is the number of pages to erase. Set a higher value here.
hth
KnarfB
2022-04-13 05:02 AM
Well, if you specify only one page to delete, only one page will be deleted.
So you should calculate the number of pages to be deleted and then specify that at NbPages.
Does it answer your question?
Regards
/Peter