cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L4 I2C_EV Interrupt without any interrupt flag

Sometimes I'm getting a I2C_EV interrupt called and none of the possible flags which can cause an interrupt are set. Only flags that are set are BUSY and TXE (ISR is 0x00008001), both of which shouldn't cause an interrupt.

void I2C1_EV_IRQHandler(void)
{
  /* USER CODE BEGIN I2C1_EV_IRQn 0 */
    if (LL_I2C_IsActiveFlag_TXIS(I2C1)) {
        sensor_i2c_txis_callback();
    } else if (LL_I2C_IsActiveFlag_TC(I2C1)) {
        sensor_i2c_tc_callback();
    } else if (LL_I2C_IsActiveFlag_RXNE(I2C1)) {
        sensor_i2c_rxne_callback();
    } else if (LL_I2C_IsActiveFlag_NACK(I2C1)) {
        LL_I2C_ClearFlag_NACK(I2C1);
        sensor_i2c_nack_callback();
    } else if (LL_I2C_IsActiveFlag_STOP(I2C1)) {
        LL_I2C_ClearFlag_STOP(I2C1);
        sensor_i2c_stop_callback();
    } else {
        MY_DEBUG("unexpected interrupt, ISR = 0x%08x\n", (unsigned int)I2C1->ISR); // prints 0x00008001
    }
  /* USER CODE END I2C1_EV_IRQn 0 */
  
  /* USER CODE BEGIN I2C1_EV_IRQn 1 */
 
  /* USER CODE END I2C1_EV_IRQn 1 */
}

The only possibility that I can think of is that the cause of the interrupt was cleared by something done in the previous interrupt call, so when the next (pending) interrupt is being called the cause is already gone. Is it possible? In that case should I just ignore the interrupt?

Thank you.

0 REPLIES 0