2023-08-09 10:24 AM - edited 2023-08-09 12:28 PM
I am using the stm32f4 discovery board and writing bare-metal drivers for the embedded flash memory.
I am facing a strange problem when writing to flash memory, to save you time for reading code and when the error happens, here is the status:
Before Error:
FLASH_CR register:
FLASH_SR register:
as you can see, PSIZE if configured correctly, but when this line of code run:
*global_pu32MemWriteVar = *(uint32_t *)argConst_pu8WriteData;
or in assembly it will be:
416 *global_pu32MemWriteVar = *(uint32_t *)argConst_pu8WriteData;
08000762: ldr r3, [pc, #216] ; (0x800083c <HAL_FLASH_Write+604>)
08000764: ldr r3, [r3, #0]
08000766: ldr r2, [r7, #4]
08000768: ldr r2, [r2, #0]
0800076a: str r2, [r3, #0]
I see PGPERR: Programming parallelism error get raised even though PSIZE is configured correctly and PG bit is set to 1.
After Error:
FLASH_CR register:
FLASH_SR register:
Solved! Go to Solution.
2023-08-09 01:40 PM
What about r2 and r3? Specifically looking to check if r3 is word-aligned.
2023-08-09 12:12 PM
What values are in r2 and r3 when that line executes?
One of your screenshots has PG=0. It needs to be PG=1.
2023-08-09 12:30 PM
sorry, I posted the incorrect screenshot, it's just I have some problems dealing with the web editor of ST forums, anyways, it's 1 (I made sure it's 1), it was just incorrect screenshot
2023-08-09 01:40 PM
What about r2 and r3? Specifically looking to check if r3 is word-aligned.
2023-08-09 08:46 PM
sure,
this is the content of R3 before STR command:
and this is the content of R2 before STR command:
2023-08-09 09:39 PM
thanks, a lot.
I discovered that the address I was trying to write to isn't word aligned