2025-02-24 10:08 AM
The memory I'm writing is 16-byte aligned (both flash destination and RAM source) and a multiple of 16 bytes in length. Using HAL to write the flash. Writing the first quadword fails with the error OPTWERR. This is quite unexpected since I am not, as far as I know, doing anything with option bytes.
The data a sizeable chunk of just over 2KB (falling within an 8KB page), but it fails on the first quadword anyway. The context is storing a user-modifiable look up table to support a UI. We use two pages as a simulated EEPROM.
The code is basically just __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_ALL_ERRORS), HAL_FLASH_Unlock(), HAL_FLASH_Program() in a loop, HAL_FLASH_Lock(). Inside HAL_FLASH_Program(), there are calls to FLASH_WaitForLastOperation(), FLASH_Program_QuadWord(), FLASH_WaitForLastOperation() - again. The second call to FLASH_WaitForLastOperation() is where the OPTWERR bit is set for some reason.
Any insight would be greatly appreciated.
2025-02-24 10:22 AM
Ah. I minuderstood. That isn't the error. I'll investigate further.