stm32在rt-thread上的SysTick(系统定时器)

在rt-thread的board.c里面已经配置了systick --> SysTick_Config( SystemCoreClock / RT_TICK_PER_SECOND );  10ms = (72M/100) * (1/72M)s   [720000tick, 1tick = 1/72 us]


systick的中断函数 SysTick_Handler()调用了 rt_tick_increase(), 自增rt_tick值


clock.c里面有几个接口函数

rt_tick_t rt_tick_get(void)  返回当前的rt_tick

void rt_tick_set(rt_tick_t tick)  设置rt_tick

rt_tick_t rt_tick_from_millisecond(rt_uint32_t ms)  根据传入值计算需多少个tick.  1ms-10ms 返回1tick, 11-20ms返回2tick ....



test: 

rt_tick_set(10000);

rt_kprintf("rt_tick_from_millisecond:%d\r\n",rt_tick_from_millisecond(1));

rt_kprintf("rt_tick_from_millisecond:%d\r\n",rt_tick_from_millisecond(11));

rt_kprintf("rt_tick_get:%d\r\n",rt_tick_get());


你可能感兴趣的:(RT-thread,STM32)