tls_os_time_delay 函數問題

發布於 2024-01-12 22:59:28

SDK版本W80X_SDK_v1.00.10

簡單加了個統計帧率:

include "wm_timer.h"

unsigned int FrameCount=0;
static void fps_timer_irq(u8 *arg)
{

printf("%f fps\n",((float)FrameCount / 5));
FrameCount=0;

}
void timer_fps(void)
{

u8 timer_id2;
struct tls_timer_cfg timer_cfg2;


timer_cfg2.unit = TLS_TIMER_UNIT_MS;
timer_cfg2.timeout = 5000;
timer_cfg2.is_repeat = 1;
timer_cfg2.callback = (tls_timer_irq_callback)fps_timer_irq;
timer_cfg2.arg = NULL;
timer_id2 = tls_timer_create(&timer_cfg2);
tls_timer_start(timer_id2);
printf("timer start\n");    

}

void UserMain(void)
{

timer_fps();
printf("\n user task \n");

while(1){
    FrameCount ++;
    tls_os_time_delay(100);
}

if DEMO_CONSOLE

CreateDemoTask();

endif

//用戶自己的task
}

當入參為100時,實際輸出5.000000 fps
當入參為1時,實際輸出500.0000 fps
就是說,我希望delay N ms,實際delay了2N ms.
是我哪個地方沒寫對麼?

查看更多

關注者
0
被浏覽
1.6k
1 個回答
isme
isme 認證專家 2024-01-15
冰鎮大西瓜

image.png
改為1000一個tick就是1ms

撰寫答案

請登錄後再發布答案,點擊登錄

發布
問題

分享
好友

手機
浏覽

掃碼手機浏覽