cancel
Showing results for 
Search instead for 
Did you mean: 

FLASH Memory erase sector

RComa.1
Associate II

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!

1 ACCEPTED SOLUTION

Accepted Solutions
Peter BENSCH
ST Employee

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

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

View solution in original post

2 REPLIES 2
KnarfB
Principal III

NbPages is the number of pages to erase. Set a higher value here.

hth

KnarfB

Peter BENSCH
ST Employee

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

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.