2020-10-21 06:59 PM
This is my code;it when run to the code in the picture, the MCU will deadvoid Flash_Test(void)
{
U32 Write_Addr = FLASH_USER_START_ADDR; //FLASH_USER_START_ADDR=((uint32_t)0x0800E000)
uint64_t data64=0x1234567812345678;
EraseInitStruct.TypeErase = FLASH_TYPEERASE_PAGES;
EraseInitStruct.Page = FLASH_USER_START_ADDR;
EraseInitStruct.NbPages = (FLASH_USER_END_ADDR - FLASH_USER_START_ADDR) / FLASH_PAGE_SIZE;
HAL_FLASH_Unlock();
if (HAL_FLASHEx_Erase(&EraseInitStruct, &PageError) != HAL_OK)
{
//HAL_FLASH_Lock();
// return 0;----
}
HAL_FLASH_Program(FLASH_TYPEPROGRAM_DOUBLEWORD, Write_Addr, data64);
}
Solved! Go to Solution.
2020-10-21 07:27 PM
> EraseInitStruct.Page = FLASH_USER_START_ADDR;
Pretty sure page should be an integer between 0 and the number of pages, not an address.
2020-10-21 07:27 PM
> EraseInitStruct.Page = FLASH_USER_START_ADDR;
Pretty sure page should be an integer between 0 and the number of pages, not an address.
2020-10-21 08:31 PM
Thanks very much!!!