2020-08-03 01:15 PM
I am currently trying as follows:
HAL_FLASH_Unlock();
HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD,0x40023BFD,10);
HAL_FLASH_Lock();
However, no data is recorded.
Solved! Go to Solution.
2020-08-03 02:17 PM
Try picking an address that's in FLASH, and aligned on a 32-bit boundary
Typically 0x08000000..0x081FFFFF (2MB)
You can only write the value once after the memory has been erased. Try not to write/erase locations your code is executing from
2020-08-03 02:17 PM
Try picking an address that's in FLASH, and aligned on a 32-bit boundary
Typically 0x08000000..0x081FFFFF (2MB)
You can only write the value once after the memory has been erased. Try not to write/erase locations your code is executing from
2020-08-04 03:51 AM
And how do I delete it, you know?
2020-08-04 05:44 AM
Erasing Flash is only possible in chunks of the sector size of the specific device.
But usually it is not a good idea to store variables in Flash, as its endurance is limited to 10000 write cycles (over temperature range, see datasheet and search for Flash memory endurance).
It might be a better idea to either use devices providing EEPROM or EEPROM emulation software.
While providing the desired write cycles this approach consumes of course the amount of Flash being the number of emulated 'EEPROM blocks'. So for example, emulating a 1KB EEPROM with guaranteed 1Mio write cycles requires 1Mio/10k*1K=100K Flash.
Good luck!
/Peter
2020-08-04 05:48 AM
STM32Cube_FW_F7_V1.14.0\Projects\STM32746G-Discovery\Examples\FLASH\FLASH_EraseProgram\Src\main.c
/* Unlock the Flash to enable the flash control register access *************/
HAL_FLASH_Unlock();
/* Fill EraseInit structure*/
EraseInitStruct.TypeErase = FLASH_TYPEERASE_SECTORS;
EraseInitStruct.VoltageRange = FLASH_VOLTAGE_RANGE_3;
EraseInitStruct.Sector = FLASH_SECTOR_23; // 0x081E0000 as I recall
EraseInitStruct.NbSectors = 1;
HAL_FLASHEx_Erase(&EraseInitStruct, &SECTORError) ;
/* Lock the Flash to disable the flash control register access (recommended
to protect the FLASH memory against possible unwanted operation) *********/
HAL_FLASH_Lock();