HAL_ERROR when i try to erase the flash memory
Hello, i'm using STM32G071RB and i need to write on the Flash Memory.
i check if i have wrote on it before. If i did, i try erase the page to re-write. At this point, i just get a HAL_ERROR of the function HAL_FLASHEx_Erase(&EraseInitStruct, &PageError).
i'm doing this:
#define FLASH_USER_START_ADDR 0x08000000
#define USEDPAGES ((uint8_t) 64)
HAL_FLASH_Unlock(); //Unlock memory write permission
FLASH_EraseInitTypeDef EraseInitStruct;
/**Define Erase Struct**/
EraseInitStruct.TypeErase = FLASH_TYPEERASE_PAGES;
EraseInitStruct.Page = FLASH_USER_START_ADDR;
EraseInitStruct.NbPages = USEDPAGES;
if (HAL_FLASHEx_Erase(&EraseInitStruct, &PageError) != HAL_OK){//Erase Pages
printf("Fail Init Erasing\n");
return 0;
}
i did the same funtions with stm32f0 and i had no troubles with it
