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.

Timer_start() does not reset the counter

Other Parts Discussed in Thread: SYSBIOS

TI-RTOS for CC13xx version 2.15.00.17

SYS/BIOS version 6.45.00.20

I am attempting to use a one shot timer sequentially with different period settings. After my first timer interrupt I reconfigure as follows:

Timer_stop(timerHandle);
Timer_setPeriodMicroSecs(timerHandle, 700);
Timer_start(timerHandle);

The period gets changed but the timer count starts from the previous value. The API document states that Timer_start() will "Reload and start the timer". Stepping into the Timer_start() function I find the following. The comment states that step 2 is to clear the counters but there is no code to do this.

/*
 *  ======== Timer_start ========
 *  1. Hwi_disable();
 *  2. Clear the counters
 *  3. Clear IFR
 *  4. Enable timer interrupt
 *  5. Start timer
 *  6. Hwi_restore()
 */
Void Timer_start(Timer_Object *obj)
{
    UInt key;

    key = Hwi_disable();

    if (obj->hwi) {
        Hwi_clearInterrupt(obj->intNum);
        Hwi_enableInterrupt(obj->intNum);
    }

    if (obj->extFreq.lo) {
        Hwi_nvic.STCSR |= 0x1;  /* start timer, select ext clock */
    }
    else {
        Hwi_nvic.STCSR |= 0x5;  /* start timer, select int clock */
    }

    Hwi_restore(key);
}

  • Matthew,
    the default timer for CC13xx devices is ti.sysbios.family.arm.cc26xx.Timer. Are you seeing something else in the debugger?
    If you look at the source you'll see that setPeriodMicroSecs returns FALSE, because that function is not implemented for this timer.
    You'll have to call setPeriod to change 'period'.

  • Stepping into Timer_setPeriodMicroSecs() it is a ti.sysbios.family.arm.m3.timer and the function sets the period correctly. However the period is loaded only when the timer expires and not in Timer_start(). As a workaround I can call Timer_setPeriodMicroSecs() before the timer has expired to set the period for the next cycle.

    Aside: I have learned since the original post that this is using systick and only one timer is possible with this driver. General purpose timers on the CC13xx/CC26xx are not supported by TI-RTOS.
  • Matthew,

    The four general purpose timers on CC13xx/CC26xx are indeed supported by TI-RTOS, with this module: ti.sysbios.family.arm.lm4.Timer

    You need to 'use' this module in the application configuration file, for example:
    Timer = xdc.useModule('ti.sysbios.family.arm.lm4.Timer');

    And you can include this header in your .c files:
    #include <ti/sysbios/family/arm/lm4/Timer.h>

    Regards,
    Scott

  • Scott,

    Thanks for the heads up on this! I tried the lm4 module and it compiles with no problem. Unfortunately, it generally goes to pieces during execution. Passing 1 to Timer_create() results in that function hanging. Using Timer_ANY or 0  results in Timer_create() working but Timer_start() attempts to use 0x40030000 which is the flash controller. The function never returns and the debugger has to be reset and reloaded before I can run anything again.

    Regards,

    --Matthew

  • Matthew,

    That 0x40030000 is definitely incorrect.  And it was the clue that led me to see the problem with the GP timer address definitions for CC13xx devices.  In a moment I will file a bug report to get this fixed in the next TI-RTOS release.

    As a workaround you can do the following… In your TI-RTOS 2.15 installation, in this directory:

    tirtos_cc13xx_cc26xx_2_15_00_17\products\bios_6_45_00_20\packages\ti\catalog\arm\cortexm3

    Copy the file “CC26xx.xs” to the file “CC13xx.xs”.  (The “CC13xx.xs” file in the installation is stale and incorrect.)

    If you clean and rebuild your project the timers should now work for you.

    Sorry you had to run into this bug!

    Regards,
    Scott

  • That did it! Thank you for your help, Scott.

    For the systick based timer question that started this, is that a bug or does the timer just function differently and require a note in the documentation? Also, for other bugs should I post them as new questions on the forum?
  • Matthew,

    OK, good, thanks for reporting back.

    For the SYSTICK question… I filed a ticket to either fix the Timer_start() documentation for this special behavior (of not reloading upon start) or to force a reload.

    For other questions or issues, yes, please post new threads for these.

    Thanks,
    Scott