test_timer.c

来自「TI DSP TMS320DM642 用定时器测试函数执行时间」· C语言 代码 · 共 37 行

C
37
字号

#include <std.h>
#include <csl.h>
#include <csl_dat.h>
#include <csl_timer.h>

TIMER_Handle hTimer;
    ///////////////////////////////////
void SetTimer(void) 
{
    TIMER_Config MyConfig = {   0x00000200, /* ctl */
   								0xffffffff, /* prd */
      							0x00000000  /* cnt */ };
    
//    IRQ_enable(IRQ_EVT_TINT0);

    hTimer = TIMER_open(TIMER_DEV1,TIMER_OPEN_RESET);
    TIMER_config(hTimer,&MyConfig);
    TIMER_setCount(hTimer,0x00000000);
	TIMER_setPeriod(hTimer,0xffffffff); //unit 1ms ->75000
		
}
/////////////////////////////////////////

Uint32 timer_start(void)
{
	TIMER_setCount(hTimer,0x00000000);
	TIMER_start(hTimer);
	return TIMER_getCount(hTimer);
}

Uint32 timer_stop(void)
{
	TIMER_pause(hTimer);
	return TIMER_getCount(hTimer);
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?