AnsweredAssumed Answered

Write and read FLASH STM32F4

Question asked by tan loi on Nov 13, 2017

I make a simple code to write and read data from address,show as below. But always get message "Cannot access target" from keliC. 

 

EraseInitStruct.TypeErase = FLASH_TYPEERASE_SECTORS;
EraseInitStruct.VoltageRange = FLASH_VOLTAGE_RANGE_3;
EraseInitStruct.Sector = GetSector(ADDR_FLASH_SECTOR_10);
EraseInitStruct.NbSectors = 1;

HAL_Delay(1000);
HAL_FLASH_Unlock();
if(HAL_FLASHEx_Erase(&EraseInitStruct,&SectorError)==HAL_OK)
{
HAL_FLASH_Program(FLASH_TYPEPROGRAM_BYTE,ADDR_FLASH_SECTOR_10,0x96);
}
HAL_FLASH_Lock();
d=*(__IO uint8_t *)ADDR_FLASH_SECTOR_10;

HAL_Delay(6000);
HAL_FLASH_Unlock();
if(HAL_FLASHEx_Erase(&EraseInitStruct,&SectorError)==HAL_OK)
{
HAL_FLASH_Program(FLASH_TYPEPROGRAM_BYTE,ADDR_FLASH_SECTOR_10,0x88);
}
d=*(__IO uint8_t *)ADDR_FLASH_SECTOR_10;
HAL_FLASH_Lock();

Outcomes