cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F3 standart peripheral library

ArturasV
Senior
Posted on June 09, 2014 at 12:29

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.

1 REPLY 1
Posted on June 24, 2014 at 17:32

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_ClearITPendingBit

which access to  ICR register and writes 1 to this bit 5 that clears the STOPF flag in the I2Cx_ISR register.

With regards.