[应用相关] 滴答定时器延时函数疑问

[复制链接]
316|0
 楼主| 两只袜子 发表于 2022-8-31 09:00 | 显示全部楼层 |阅读模式
在stm32f1xx_ll_utils.c中提供的延时函数,以下标红语句为什么要多加1呢?延时1ms不就变成2ms了吗?

void LL_mDelay(uint32_t Delay)
{
  __IO uint32_t  tmp = SysTick->CTRL;  /* Clear the COUNTFLAG first */
  /* Add this code to indicate that local variable is not used */
  ((void)tmp);

  /* Add a period to guaranty minimum wait */
  if (Delay < LL_MAX_DELAY)
  {
    Delay++;
  }

  while (Delay)
  {
    if ((SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk) != 0U)
    {
      Delay--;
    }
  }
}

您需要登录后才可以回帖 登录 | 注册

本版积分规则

2122

主题

8121

帖子

11

粉丝
快速回复 在线客服 返回列表 返回顶部