Youssouf Coulibaly

HAL I2C gets into endless IRQ Handler.

Discussion created by Youssouf Coulibaly on Mar 13, 2018
Latest reply on May 16, 2018 by avi_crak.videocrak

Hi everybody,

 

I am using the STM32L071CZ type within an I2C interface to communicate with my external device.

For some reasons, it appears that the code is stilling in I2C1_IRQHandler.

I am using the I2C_Mem_Write_DMA and I2C_Mem_Read_DMA  and somehow the code is in interrupt endless loop. 

And when the issue happens the content of ISR register is always set to 0x8003.

 

 

void I2C1_IRQHandler(void)
{
      if(hi2c1->Instance->ISR & (I2C_FLAG_BERR | I2C_FLAG_ARLO | I2C_FLAG_OVR))
      {
            HAL_I2C_ER_IRQHandler(hi2c1);
      }
      else
      {
            HAL_I2C_EV_IRQHandler(hi2c1);
      }
}

 

in HAL_I2C_EV_IRQHandler(hi2c1) it is getting called the following function.

 

static HAL_StatusTypeDef I2C_Master_ISR_DMA(struct __I2C_HandleTypeDef *hi2c, uint32_t ITFlags, uint32_t ITSources) 
{
      uint16_t devaddress = 0U;
      uint32_t xfermode = 0U;

 

      /* Process Locked */
      __HAL_LOCK(hi2c);

      ************************

      ************************

      else if(((ITFlags & I2C_FLAG_STOPF) != RESET) && ((ITSources & I2C_IT_STOPI) != RESET))
      {
            /* Call I2C Master complete process */
            I2C_ITMasterCplt(hi2c, ITFlags);
      }

 

      /* Process Unlocked */
      __HAL_UNLOCK(hi2c);

 

   return HAL_OK;
}

 

In I2C_Master_ISR_DMA function, the  __HAL_LOCK return a busy flag and cannot proceed with upper layer function in my application. Basically, the program is constantly in interrupt with dead lock. 

 

How this could happened on I2C line ?

Is there  an issue in the HAL itself because it is reponsible to take care of all interrupts and lock/unlock semaphore boolean ?

 

Thanks in advance for your supports.

 

Best regards,

Outcomes