Flash write HARD FAULT
Whenever there is an attempt to write to FLASH memory, the program throws a hardware fault. This issue is on the branch flash-operations. Further investigation is needed to find the root cause.
Some details regarding the issue:
- The FLASH is unlocked and the is verified by reading the corresponding bit
LOCKin theCRregister, after the unlock operation, performed throughHAL_FLASH_Unlock(). - After the unlock operation, the
HAL_FLASH_Programis called, which it should write the new data in FLASH. However theHAL_FLASH_Programfunctions causes a HARD FAULT, when the line*(__IO uint16_t*)Address = Data;(at line 834) is executed, called from theFLASH_Program_HalfWordfunction in thestm32f1xx_hal_flash.cfile.
Two screenshots and the debug files are attached below.

