cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F746G-DISCO, FLASH

AD�?b
Senior

Why does flasch memory lose saved data after being read and written after power off?

Andrzej

1 ACCEPTED SOLUTION

Accepted Solutions

> 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?

View solution in original post

19 REPLIES 19
KnarfB
Principal III

Sorry leader, but this is too little information. I'm using 20+ of those boards for years and they never did that to me.

AD�?b
Senior

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

KnarfB
Principal III

FLASH_SECTOR_4 != FLASH_SECTOR_3 ?

I changed:

total_time = * (__ IO uint32_t *) FLASH_SECTOR_3; // reading from FLASH It still does not work

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 ?

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..

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.

> 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?

I want to erase but I don't know how.

STM32Cube_FW_F7_V1.16.0\Projects\STM32746G-Discovery\Examples\FLASH\FLASH_EraseProgram

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..