cancel
Showing results for 
Search instead for 
Did you mean: 

HAL ECC error is not being acknowledged by __HAL_FLASH_GET_FLAG(FLASH_FLAG_ECCR_ERRORS)

KStew.1
Associate II

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

1 REPLY 1
TDK
Guru

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))

 

If you feel a post has answered your question, please click "Accept as Solution".