HAL_Delay()
- 原理:基于SysTick ISR中的变量自增,定时精度与滴答定时器的频率有关,一般为ms级;
- 注意:SysTick的中断优先级必须高于其他任务优先级,否则如果其他中断程序中调用了此延时函数,就睡导致 中断被锁
- 通过
HAL_NVIC_SetPriority
设置中断优先级
Attention 尽量不要在中断程序中调用延时函数
官方说明
Care must be taken when using HAL_Delay(), this function provides accurate
delay (in milliseconds) based on variable incremented in SysTick ISR. This
implies that if HAL_Delay() is called from a peripheral ISR process, then
the SysTick interrupt must have higher priority (numerically lower)
than the peripheral interrupt. Otherwise the caller ISR process will be blocked.
To change the SysTick interrupt priority you have to use HAL_NVIC_SetPriority() function