cancel
Showing results for 
Search instead for 
Did you mean: 

Write and read FLASH STM32F4

tan loi
Associate II
Posted on November 13, 2017 at 11:21

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();
0 REPLIES 0