STM32
直播中

王莉

7年用户 1206经验值
私信 关注
[问答]

IIC异常关闭中断,导致滴答定时器运行错误的原因?

```
static HAL_StatusTypeDef I2C_WaitOnFlagUntilTimeout(I2C_HandleTypeDef *hi2c, uint32_t Flag, FlagStatus Status, uint32_t Timeout, uint32_t Tickstart)
{
  /* Wait until flag is set */
  while (__HAL_I2C_GET_FLAG(hi2c, Flag) == Status)
  {
    /* Check for the Timeout */
    if (Timeout != HAL_MAX_DELAY)
    {
      if (((HAL_GetTick() - Tickstart) > Timeout) || (Timeout == 0U))
      {
        hi2c->PreviousState     = I2C_STATE_NONE;
        hi2c->State             = HAL_I2C_STATE_READY;
        hi2c->Mode              = HAL_I2C_MODE_NONE;
        hi2c->ErrorCode         |= HAL_I2C_ERROR_TIMEOUT;

        /* Process Unlocked */
        __HAL_UNLOCK(hi2c);

        return HAL_ERROR;
      }
    }
  }
  return HAL_OK;
}

回帖(1)

刘婷婷

2024-3-21 14:08:28
我理解这里不会影响systick的运行,但是需要排除是否由于这个I2C的操作导致产生硬件错误中断后,进入错误中断,systick运行,或者I2C中断在一直运行,导致systick中断不运行。
举报

更多回帖

发帖
×
20
完善资料,
赚取积分