Other Parts Discussed in Thread: SYSBIOS
Tool/software: TI-RTOS
Hi,
I am using the CC2640, SysBios 2.21.0.6 on CCS7.
I want to use the timer module of SysBios to call a certain function after a certain time. Depending on the status of a state machine there are different functions to call and also different delay times, so I need to set the function and delaytime each time before I start the timer.
When I measure the delay time of timer interrupt with a scope it is always much longer than I programmed. Below is one example where I start the timer after a number bytes received from UART and 80µsec later I sample an input and set an output. With the scope I can detect that the delaytime is not 80µsec but 6 ms.
Any idea about the reason for that? Thanks in advance
My code is as follows:
#include <ti/sysbios/hal/Timer.h>
#define SCB_uSec_SampleFeedback 80 // check feedback after 0.8 * bit time
Timer_Handle SCB_Timer;
void SCB_TimerISR_Sample_Feedback_and_Execute(UArg arg0)
{
PIN_setOutputValue(&SYSPinState, Board_EPI12, 1); // set Pin EPI12 to high
.... other code to continue followed
Semaphore_post(Task_SCB_Semaphore);
}
void Task_SCB(UArg arg0, UArg arg1)
{
Timer_Params SysTimerParams;
Timer_Params_init(&SysTimerParams);
SysTimerParams.periodType = Timer_PeriodType_MICROSECS;
SysTimerParams.runMode = Timer_RunMode_ONESHOT;
SysTimerParams.startMode = Timer_StartMode_USER ;
SCB_Timer = Timer_create(Timer_ANY, SCB_TimerISR_Sample_Feedback_and_Execute, &SysTimerParams, NULL);
if (!SCB_Timer) System_abort("SCB timer create failed");
.... other code and while loop of the task to continue
.... after a certain amouont of bytes from the UART received
Timer_stop(SCB_Timer);
Timer_setFunc(SCB_Timer, SCB_TimerISR_Sample_Feedback_and_Execute, 0);
Timer_setPeriodMicroSecs(SCB_Timer, SCB_uSec_SampleFeedback);
Timer_start(SCB_Timer);
Semaphore_pend(Task_SCB_Semaphore, SCB_TimoutTicksGeneral);
}