2023-10-13 02:39 PM
I am running into an ECC error when writing to flash when the device is powering down - unfortunately this is a state I cannot control. In the NMI handler when the device boots up I read through the flash and an ECC error pops up and the NMI Handler is triggered. In my NMI handler checking __HAL_FLASH_GET_FLAG(FLASH_FLAG_ECCR_ERRORS) is not returning any flags, but READ_BIT(FLASH->ECCR, (FLASH_FLAG_ECCR_ERRORS)) is returning a flag. Why is this is it a bug with the HAL?
I am on a stm32l476rc currently using HAL 1.11.1.0
2023-10-13 07:02 PM
The __HAL_FLASH_GET_FLAG definition is available in the source. Should be straightforward to follow the logic it uses.
#define __HAL_FLASH_GET_FLAG(__FLAG__) ((((__FLAG__) & FLASH_FLAG_ECCR_ERRORS) != 0U) ? \
(READ_BIT(FLASH->ECCR, (__FLAG__)) != 0U) : \
(READ_BIT(FLASH->SR, (__FLAG__)) != 0U))