下面是我写的一个简单的例子,我看了一下寄存器,CLKDI=6,我想确定一下,中断是不是80us触发一次,用的是clock()函数也不知道对不对,但是最后仿真如图,是不是出现错误了,80us不是等于80000个吗?
#include <xdc/std.h>
#include <xdc/runtime/System.h>
#include <ti/sysbios/knl/Task.h>
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Clock.h>
#include <xdc/runtime/Error.h>
#include <xdc/cfg/global.h>
#include <ti/sysbios/timers/timer64/Timer.h>
#include <time.h>
void masterTask();
void tickFxn();
#define CLKDIV (0x02280004)
Clock_Handle clk2;
Clock_Handle clk1;
xdc_runtime_Types_FreqHz *freq;
Timer_Handle timerHandle;
UInt i=0;
time_t time1,time2;
time_t time_n[500];
volatile Bool flag=0;
void masterTask()
{
System_printf("开启定时器:");
time1=clock();
Timer_start(timerHandle);
while(1){
if(flag){
time2=clock();
time_n[i]=time2-time1;
i++;
time1=time2;
if(i==500)
BIOS_exit(0);
flag = 0;
}
}
}
void tickFxn()
{
if(flag)
BIOS_exit(0);
flag=1;
}
/*
* ======== main ========
*/
Int main()
{
Error_Block eb;
Task_Handle taskHandle;
Timer_Params timerParams;
Error_init(&eb);
Timer_Params_init(&timerParams);
timerParams.period = 80;
timerParams.periodType = Timer_PeriodType_MICROSECS;
timerParams.startMode=Timer_StartMode_USER;
timerParams.runMode = Timer_RunMode_CONTINUOUS;
//timerParams.
timerParams.emuMgtInit.free=1;
timerHandle = Timer_create(8, tickFxn, &timerParams, &eb);
if(timerHandle == NULL){
System_abort("创建定时失败/n");
}
taskHandle = Task_create(masterTask, NULL, &eb);
if(taskHandle == NULL){
System_abort("创建任务失败/n");
}
BIOS_start(); /* does not return */
return(0);
}