This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

SYS/BIOS中使用定时器不准

Other Parts Discussed in Thread: SYSBIOS

使用SYSBIOS6.35.04.50,按照User Guid里面想产生200us的定时器模块,可经过测试产生的定时器的周期不受控制,Period不管设置成什么数值,周期都在1ms左右,不知道是什么原因?希望高人指点,谢过了!代码如下:

/* ======== HwiHookExample.c ========
* This example demonstrates basic Hwi hook usage. */
#include <xdc/std.h>
#include <xdc/runtime/Error.h>
#include <xdc/runtime/System.h>
#include <xdc/runtime/Timestamp.h>
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Task.h>
#include <ti/sysbios/hal/Timer.h>
#include <ti/sysbios/hal/Hwi.h>
#include "led.h"
int state=0;
Timer_Handle myTimer;
/* ======== myTimerFunc ========
* Timer interrupt handler */
Void myTimerFunc(UArg arg)
{
 int i;
 led_ON_OFF(1);
 for(i=0;i<5000;i++);
 led_ON_OFF(0);
 for(i=0;i<5000;i++);
}
/* ======== myTaskFunc ======== */
Void myTaskFunc(UArg arg0, UArg arg1)
{
 Timer_setPeriodMicroSecs(myTimer,200);
 Timer_start(myTimer);
  while(1);
}
/* ======== main ======== */
Int main(Int argc, Char* argv[])
{
 Task_Params taskParams;
 Task_Handle task0;
 Error_Block eb;
 Timer_Params timerParams;
 Error_init(&eb);
 led_init();
 /* Create 1 task with priority 15 */
 Task_Params_init(&taskParams);
 taskParams.stackSize = 100;
 taskParams.priority = 15;
 task0 = Task_create(myTaskFunc, &taskParams, &eb);
 if (task0 == NULL) System_abort("Task create failed");
 Timer_Params_init(&timerParams);
 //timerParams.extFreq.lo=5000;
 //timerParams.extFreq.hi=0;
 timerParams.period = 2000000;
 timerParams.runMode = Timer_RunMode_CONTINUOUS;
 timerParams.startMode = Timer_StartMode_AUTO;
 timerParams.periodType = Timer_PeriodType_MICROSECS;
 myTimer = Timer_create(Timer_ANY, myTimerFunc, &timerParams, &eb);
 if (myTimer == NULL)  System_abort("Timer create failed");
 BIOS_start();
 return (0);
}