找回密码
 注册
搜索
查看: 557|回复: 2

关于定时器的疑问

[复制链接]
发表于 2009-9-24 10:55:22 | 显示全部楼层 |阅读模式
代码片段如下:
   StartTimer(NFC_TIMER, 2000, timer_demo);
   while(1)
   {
       if (g_tst_flag == 0)
            break;
   }

void timer_demo(void)
{
    StopTimer(NFC_TIMER);
    g_tst_flag = 0;
    gui_move_text_cursor(UI_device_width / 2, UI_device_height / 2);
    gui_print_text(L"Hello from timer!");
    gui_BLT_double_buffer(0, 0, UI_device_width - 1, UI_device_height - 1);
}

定时回调函数始终没有被调用。之前去掉死循环,回调正常。希望高人指点,谢谢!
发表于 2009-9-24 11:48:41 | 显示全部楼层
CPU都取运行死循环了,哪里还有空闲处理定时消息!
if (g_tst_flag == 0)应该用个Semaphore,mutex,Event之类的阻塞。
点评回复

使用道具 举报

 楼主| 发表于 2009-9-24 12:36:28 | 显示全部楼层
看来是我理解的问题。我以为定时器的回调函数是像单片机的中断一样运行的。
谢谢指教!
点评回复

使用道具 举报

高级模式
B Color Image Link Quote Code Smilies

本版积分规则

Archiver|手机版|小黑屋|52RD我爱研发网 ( 沪ICP备2022007804号-2 )

GMT+8, 2024-10-7 07:35 , Processed in 0.056371 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表