2017-11-13 02:21 AM
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();