2017-05-17 07:12 AM
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
2017-05-17 07:33 AM
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.
2017-05-17 09:42 AM
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