cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F746G-DISCO, STM32CubeIDE

ADębs.1
Senior

I want to write to FLASH and read. Why doesn't it record?

HAL_FLASH_Unlock();
FLASH_Erase_Sector(FLASH_SECTOR_7, VOLTAGE_RANGE_3);
HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, FLASH_SECTOR_7, 300);
HAL_FLASH_Lock();
set_time = *(__uint32_t*) FLASH_SECTOR_7;

Compiles without error.

Andrzej

1 ACCEPTED SOLUTION

Accepted Solutions
Petr DAVID
ST Employee

Hello ADebs.1,

it seems to me the code is not complete. Take a look at the provided example FLASH_EraseProgram available in STM32F7Cube FW package. Recommended function for erase should be HAL_FLASHEx_Erase which next to the FLASH_Erase_Sector function also obtain few other operations needed for correct erasing process.

Please click on Select as Best if my reply fully answered your question. This will help other users with the same problem to find the solution faster!

View solution in original post

3 REPLIES 3
Petr DAVID
ST Employee

Hello ADebs.1,

it seems to me the code is not complete. Take a look at the provided example FLASH_EraseProgram available in STM32F7Cube FW package. Recommended function for erase should be HAL_FLASHEx_Erase which next to the FLASH_Erase_Sector function also obtain few other operations needed for correct erasing process.

Please click on Select as Best if my reply fully answered your question. This will help other users with the same problem to find the solution faster!

Thank you.

After compiling, I have no error, the program hangs and I have to erase all memory with the programmer.

An error at 0xFFFFFFFE is then reported.

I will try as suggested and let me know.

greetings

Andrzej

ADębs.1
Senior

Hello Petr

I am sending the program I wrote as you advised. But something is not right. If I reset the STM32 memory with the programmer, I enter debag without a problem. The second time I want to enter the same, it throws debag. I need to reset the memory with my programmer. It seems to write to FLASH, but when I look at the address 0x080C000 (FLASH_SECTOR_7), I do not see the data saved.

What is the cause?

greetings

Andrzej