stm32毫秒ms延时,HAL_Delay()

STM32的HAL库确实提供了毫秒级的延时函数,即HAL_Delay()函数。这个函数使用SysTick定时器来实现延时,并且可以配置为微秒级的延时。


//stm32l4xx_hal.c
/**
  * @brief This function provides minimum delay (in milliseconds) based
  *        on variable incremented.
  * @note In the default implementation , SysTick timer is the source of time base.
  *       It is used to generate interrupts at regular time intervals where uwTick
  *       is incremented.
  * @note This function is declared as __weak to be overwritten in case of other
  *       implementations in user file.
  * @param Delay  specifies the delay time length, in milliseconds.
  * @retval None
  */
__weak void HAL_Delay(uint32_t Delay)
{
  uint32_t tickstart = HAL_GetTick();
  uint32_t wait = Delay;

  /* Add a period to guaranty minimum wait */
  if (wait < HAL_MAX_DELAY)
  {
    wait += (uint32_t)uwTickFreq;
  }

  while ((HAL_GetTick() - tickstart) < wait)
  {
  }
}

相关推荐

  1. stm32毫秒ms,HAL_Delay()

    2024-07-10 17:32:10       26 阅读
  2. STM32系统滴答定时器SysTick实现精确ms和us

    2024-07-10 17:32:10       56 阅读
  3. STM32 系统时钟初始化函数和函数

    2024-07-10 17:32:10       29 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-10 17:32:10       99 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-10 17:32:10       107 阅读
  3. 在Django里面运行非项目文件

    2024-07-10 17:32:10       90 阅读
  4. Python语言-面向对象

    2024-07-10 17:32:10       98 阅读

热门阅读

  1. nftables(4)表达式(2)主要表达式(PRIMARY EXPRESSIONS)

    2024-07-10 17:32:10       22 阅读
  2. C++八股(三)之虚函数

    2024-07-10 17:32:10       29 阅读
  3. Linux下mysql数据库的导入与导出以及查看端口

    2024-07-10 17:32:10       30 阅读
  4. Mybatis-Flex各种查询,强烈建议收藏

    2024-07-10 17:32:10       33 阅读
  5. Mybatis-plus学习

    2024-07-10 17:32:10       23 阅读
  6. mysql函数 last_insert_id()

    2024-07-10 17:32:10       28 阅读
  7. DateTimeUtils

    2024-07-10 17:32:10       24 阅读
  8. CSS:选择器 / 14种类型

    2024-07-10 17:32:10       28 阅读
  9. css中文字书写方向

    2024-07-10 17:32:10       26 阅读
  10. 19.JWT

    19.JWT

    2024-07-10 17:32:10      29 阅读
  11. 实证Stata代码命令汇总

    2024-07-10 17:32:10       21 阅读
  12. 将 build.gradle 配置从 Groovy 迁移到 Kotlin

    2024-07-10 17:32:10       26 阅读