cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot read correct data from STM32 internal FLASH

Stelios67
Associate

Hi,

I am using STM32u585 MCU.

It has 2 FLASH banks of 1MB each one.

In initially I read correct data (64 bytes) from page 0 of FLASH bank 2, at address 0x0810.0000

After that I erase the FLASH page.

In CubeIDE Memory Browser window I can see that the page is erased.

When I try to read the same address from FLASH I do not read 0xFF bytes (as expected) but I read the previous bytes before page erase.

When I read the contents of another FLASH page (bank 2 page 1 - the next page) it reads correct data and if after that I read the contents of page 0 I read the correct page contents (0xFF) bytes.

The same happens if I read bytes into the page 0, when I try to read the page I receive the previous bytes.

This happens to every FLASH page.

The MCU behaves like there is a FLASH "cache" memory that holds the last page contents and if I want to read the new data bytes I have to reset the "cache" by reading another page.

Is there an explanation for this? How can I read the page I have just programmed without another FLASH read?

2 REPLIES 2
SofLit
ST Employee

Hello,

Did you try reading the Flash after erasing the page without using the debugger? 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
Stelios67
Associate

Hi, 

yes, we have tried that. We have tried to print the bytes we read.

The problem is solved if we disable the ICACH_CR_EN bit before we read the flash bytes and re-enable it after the read.
Or if we disable it before the flash erase or programming and re-enable it after.