2014-06-09 03:29 AM
Hello. I'm working with I2C at the moment, trying to Read data from ADXL345 accelerometer. I found out in lib ''stm32f30x_i2c.c'' that:
void I2C_ClearITPendingBit(I2C_TypeDef* I2Cx, uint32_t I2C_IT){ /* Check the parameters */ assert_param(IS_I2C_ALL_PERIPH(I2Cx)); assert_param(IS_I2C_CLEAR_IT(I2C_IT)); /* Clear the selected flag */ I2Cx->ICR = I2C_IT;}and void I2C_ClearFlag(I2C_TypeDef* I2Cx, uint32_t I2C_FLAG){ /* Check the parameters */ assert_param(IS_I2C_ALL_PERIPH(I2Cx)); assert_param(IS_I2C_CLEAR_FLAG(I2C_FLAG)); /* Clear the selected flag */ I2Cx->ICR = I2C_FLAG; }Shouldn't I2C_ClearITPendingBit be I2Cx->ISR = I2C_FLAG; ?Because i'm not able to clear I2C_IT_STOPF , using I2C_ClearITPendingBit. Thanks for your answer in advance.2014-06-24 08:32 AM
Hi,
The I2C_ClearITPendingBit cannot be I2Cx->ISR = I2C_FLAG;since the ISR is a read-only register used to get FLAG status.So to clear I2C_IT_STOPF bit, you have to use I2C_ClearITPendingBitwhich access to ICR register and writes 1 to this bit 5 that clears the STOPF flag in the I2Cx_ISR register.With regards.