2021-02-10 10:46 AM
Why does flasch memory lose saved data after being read and written after power off?
Andrzej
Solved! Go to Solution.
2021-02-11 06:41 AM
> Do you erase it? No
Programming can only flip 1 bits to 0 bits. Erase is needed for the other way round. Why do you expect it to work without erase?
2021-02-10 11:47 AM
Sorry leader, but this is too little information. I'm using 20+ of those boards for years and they never did that to me.
2021-02-11 02:34 AM
Hi
I want:
1.Read the value from FLASH after power on
2. After aborting, save the current value in FLASH
I am doing:
1. my variable is uint32_t total_time; // save to FLASH in 87
2. I read total_time = * (__ IO uint32_t *) FLASH_SECTOR_4; // reading from FLASH at 180
3.unlock FLASH HAL_FLASH_Unlock (); // FLASH unlock for writing in 181
4. in the interrupt I write the variable
void HAL_GPIO_EXTI_Callback (uint16_t GPIO_Pin) // interrupt for writing to FLASH
{ if (GPIO_Pin == STOP_Pin)
HAL_FLASH_Program (FLASH_TYPEPROGRAM_WORD, FLASH_SECTOR_3, total_time); // saving to FALSH
} in 1005
Almost every time I read a different recorded value after turning on the power.
Andrzej
I include main.c
2021-02-11 03:08 AM
FLASH_SECTOR_4 != FLASH_SECTOR_3 ?
2021-02-11 03:40 AM
I changed:
total_time = * (__ IO uint32_t *) FLASH_SECTOR_3; // reading from FLASH It still does not work
2021-02-11 04:18 AM
Do you erase it? Do you look at the error codes?
How about you write incrementally, deeper into the sector, so you don't have to erase at every cycle ?
2021-02-11 04:37 AM
Do you erase it? No
Do you look at the error codes? No
How about you write incrementally, deeper into the sector, so you don't have to erase at every cycle?
I prefer to erase the entire sector one time.
But I do not know how to do it.
2021-02-11 06:41 AM
> Do you erase it? No
Programming can only flip 1 bits to 0 bits. Erase is needed for the other way round. Why do you expect it to work without erase?
2021-02-11 10:57 AM
I want to erase but I don't know how.
2021-02-11 11:37 AM
STM32Cube_FW_F7_V1.16.0\Projects\STM32746G-Discovery\Examples\FLASH\FLASH_EraseProgram