Skip to main content
ADębs.1
Senior
June 22, 2021
Solved

STM32F746G-DISCO, STM32CubeIDE

  • June 22, 2021
  • 2 replies
  • 865 views

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

This topic has been closed for replies.
Best answer by Petr DAVID

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!

2 replies

Petr DAVID
Petr DAVIDBest answer
ST Employee
June 25, 2021

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!

ADębs.1
ADębs.1Author
Senior
June 25, 2021

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
ADębs.1Author
Senior
June 25, 2021

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