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.

RTOS/CC2640: Measured Delay time of timer module does not match defined delay time

Part Number: CC2640
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);

}

  • Berthold,

    Let me make sure I understand. From the time you call Timer_start() until the SBC_TimerISR() function is invoked, should measure 80 usec. But you are measuring 6 msec with your oscilloscope. I assume you measure the end-point when pin EPI12 goes high, but how are you measuring the start-point?

    Is it possible that the timer input clock is incorrect?

    Would you call Timer_getFreq() to verify the timer input clock is running at 24 MHz.

    Another idea would be to setup a simple continuous timer which toggles your pin in the timer ISR. Maybe you could use this to verify the timer configurations are correct. For example, setup a continuous timer with a 10 msec period. Verify this timing with your oscilloscope. Now reduce the period to 100 usec and verify the period is still accurate.

    ~Ramsey

  • Hi Ramsey,

    thanks for reply - you really brought me on the right track.

    Just before the Timer_start() there is a UART_read() of 1 byte. I took as a start point of measurement the stop bit of the transferred UART byte and expected that the program to continue right after one byte is transferred over the UART. In fact there is a delay of 6ms from the stop bit at the UART RX until the program continues.I am reading in the UART byte in UART_MODE_CALLBACK and I just realized that due to the FIFO the callback function is not called after one byte is read in. When I manually disable the FIFO with the CC26xxWare there is no more delay, but unfortunately the UART driver misses bytes in a next UART_read() of 5 bytes.


    I need to think about how to redesign the code ....

    Thanks again

    Berthold

  • Berthold,

    Okay. Thanks for the update.

    ~Ramsey