Closed tomatsu closed 4 months ago
Hello @tomatsu,
Thank you for your contribution, the macro you provided:
#define __HAL_FLASH_CLEAR_FLAG(__FLAG__) ((FLASH->SR) &= ~(__FLAG__))
is intended to clear specific flags by performing a bitwise AND operation with the complement of the flag. This method is typically used for flags that are reset by writing 0. However, as per RM0394 Rev 4 page 102 the flags in the FLASH->SR
register are cleared by writing 1.
Therefore, the correct definition should be:
#define __HAL_FLASH_CLEAR_FLAG(__FLAG__) ((FLASH->SR) = (__FLAG__))
This aligns with our driver's implementation. As for the issue you raised, since it is not relevant, I will proceed to close it. Thank you for your comprehension.
With regards,
I am experiencing an error when I write data to EEPROM. I suspect that __HAL_FLASH_CLEAR_FLAG does not property clear FLASH->SR, and the macro should be defined as follows.
#define __HAL_FLASH_CLEAR_FLAG(__FLAG__) ((FLASH->SR) &= ~(__FLAG__))
I would appreciate if you could take a look at the code.