cancel
Showing results for 
Search instead for 
Did you mean: 

Problem using 32-bit data in internal Flash on STM32F407.

bo2
Associate
Posted on May 17, 2017 at 16:12

Hello.

I have problem writing 32-bits word in internal Flash at certain addresses in STM32F407. It is impossible to write 32-bit data at address 0x080E000A. If I try to write data at 0x080F0000 it works perfectly. If I try to write at 0x080F0002 I read 0xFFFFFFFF. 0x080F0004 does not work either.

What can I do wrong? 

Is there any busy flag to read?

Here is my not working code:

address = 0x080F0004;

Pointer = (uint32_t *)0x080F0004;

HAL_FLASH_Unlock();

FLASH_Erase_Sector(11,FLASH_VOLTAGE_RANGE_3);

HAL_FLASH_Lock();

ReadData = *Pointer;

data = 0xABBABAAB;

HAL_FLASH_Unlock();

HAL_FLASH_Program(TYPEPROGRAM_WORD, address, data);

HAL_FLASH_Lock();

ReadData = *Pointer;

Best regards.

/Bosse

2 REPLIES 2
Posted on May 17, 2017 at 16:33

Not sure if the array support unaligned writes, I'd generally avoid doing so. Avoid also micro-analyzing the situation in the debugger.

Make sure the error/status flags are cleared. The extra lock/unlock are not required. Print out the values to a terminal, and ideally try checking if ReadData == 0xFFFFFFFF prior to any write attempt.

The functions should loop until complete, or an error, check the return status rather than ignore it. If there is a problem it will likely tell you.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on May 17, 2017 at 16:42

Not sure if the array support unaligned writes, I'd generally avoid doing so.

+1. But as a matter of fact, RM0090 does not mention alignment requirement (except that writes should not cross a 128-bit boundary).

ST: please comment, and fix documentation accordingly.

JW