Cortex-M3 的内核中包含一个 SysTick 时钟。SysTick 为一个 24 位递减计数器,SysTick 设定初值并使能后,每经过 1 个系统时钟周期,计数值就减 1。计数到 0 时,SysTick 计数器自动重装初值并继续计数,同时内部的 COUNTFLAG 标志会置位,触发中断 (如果中断使能情况下)。


-
ms clock setting:
1.1 Set 1ms interrupt

1.2 ISR

1.3 ISR called

-
us Delay
/**
-
@brief us级延时,滴答定时器为向下计数
-
@param count: 延时us数
-
@retval None
*/
void bsp_delay_us(uint32_t count)
{
uint32_t now_cnt;
uint32_t target_cnt;now_cnt = SysTick->VAL;
target_cnt = __modulus_us * count;if (now_cnt > target_cnt)
{
target_cnt = now_cnt - target_cnt;
}
else
{
target_cnt = SysTick->LOAD - (target_cnt - now_cnt);
}
while (target_cnt <= SysTick->VAL);
}/* 滴答定时器时钟源为AHB的1/8,同时转化为us /
__modulus_us = SystemCoreClock / 1000000;
/ configure the systick handler priority */
NVIC_SetPriority(SysTick_IRQn, 0x00U);









![[附源码]计算机毕业设计抗疫医疗用品销售平台Springboot程序](https://img-blog.csdnimg.cn/ec366047d3b44acb850d006652720e8f.png)








