大家好!
我尝试在回调模式下使用计时器来组织1ms 延迟函数(使用 NoRTOS)
全局变量
volatile bool lock = false;
从 main 调用:
Board_init();
timer_init();
timer_handle timer = station_ms_timer_config ();
LOCK = false;
如果(Timer_start (timer)=TIMER_STATUS_ERROR)
{
while (1);
}
while (!lock);
/* smth */
防御:
Timer_handle station) station) ms_timer_config (void)
{
Timer_Params timerParams;
Timer_Params_init (&timerParams);
timerParams.period = 1000;
timerParams.periodUnits = Timer_Period_US;
timerParams.timerMode = Timer_OneShot_callback;
timerParams.timerCallback = timer_callback;
Timer_handle local_timer = Timer_open (Board_TIMER0、&timerParams);
if (local_timer == NULL)
{
while (1);
}
返回 LOCAL_TIMER;
}
这是回调:
void timer_callback (Timer_handle myHandle)
{
LOCK = true;
}
通过调试器、我可以看到我永远不会进行回调、原因可能是什么?
此致、Boris