设置的cpu频率为1GHz,Tick period 是1000us,
#include <xdc/std.h>
#include <xdc/runtime/System.h>
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Clock.h>
Void clk0Fxn(UArg arg0);
Void clk1Fxn(UArg arg0);
volatile int count = 0;
/*
* ======== main ========
*/
Void main()
{
Clock_Handle clk2;
Clock_Params clkParams;
/* Create a periodic Clock Instance with period = 5 system time units */
Clock_Params_init(&clkParams);
clkParams.period = 1000;
clkParams.startFlag = TRUE;
Clock_create(clk0Fxn, 5, &clkParams, NULL);
BIOS_start();
}
Void tsk0Fxn(UArg arg0, UArg arg1)
{
Int num = 0;
xdc_runtime_Types_FreqHz cpuFreq ;
BIOS_getCpuFreq(&cpuFreq);
/* To demonstrate the exchange function */
while(count < 180){
num++;
}
System_printf("count = 0x%x\n",count);
}
/*
* ======== clk0Fxn =======
*/
Void clk0Fxn(UArg arg0)
{
UInt32 time;
count = count + 1;
time = Clock_getTicks();
System_printf("System time in clk0Fxn = %lu\n", (ULong)time);
}
clk0Fxn函数每次调用 count技术加1,但是180秒count技术并没有到180,而是小于180,难道clock不是计数到1000 之后立马从0开始重新计数吗,为什么会和实际的时间有偏差