2020-05-10 02:07 AM
I checked I2C interrupt flags, when I realized at new interrupt bit 16 is also checked for SR1, bit 17 is also checked for SR2 registers, despite they are 16-bit registers. Why?
See attached picture for details.
Thanks in advance!
2020-05-10 06:09 AM
It's a 32 bit register, just the upper 16 bits are reserved.
The 16th bit is used by HAL to hold which status register the flag is in.
#define __HAL_I2C_GET_FLAG(__HANDLE__, __FLAG__) ((((uint8_t)((__FLAG__) >> 16U)) == 0x01U) ? \
(((((__HANDLE__)->Instance->SR1) & ((__FLAG__) & I2C_FLAG_MASK)) == ((__FLAG__) & I2C_FLAG_MASK)) ? SET : RESET) : \
(((((__HANDLE__)->Instance->SR2) & ((__FLAG__) & I2C_FLAG_MASK)) == ((__FLAG__) & I2C_FLAG_MASK)) ? SET : RESET))
Maybe you're wanting to use I2C_SR1_SB, which is the register level definition.
2020-05-10 02:26 PM
Thank you for the clarification! :)
I did not plan to use SB, I just wanted to know if I need to check 16th bit when I use my own raw code instead of HAL. :) It is working only checking the actual bit to the corresponding flag, as you wrote the 16th bit is only for HAL. Thank you!