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/CC1310: Timer issue

Part Number: CC1310
Other Parts Discussed in Thread: SYSBIOS

Tool/software: TI-RTOS

I need to generate 3kHz sine using CC1310, so I am using Timer object (not a Clock) with 45uS interval. In callback function I calculate sine value and feed it to PWM. Under CCS this approach is working, I could see 3kHz sine (after RC filtering). But when I stop debug-session and let my board run alone - timer is not running properly anymore, seems like it is running chaotically, not periodically, with interval way longer then expected, sometime seconds. I have simplified callback function, leave there just led toggling, watching it with oscilloscope, but problem is still there. Code sample is below. I have no other Timers to take all resources, I have two tasks and few Clocks, but I stop them temporally to debug this issue. I am on CCS 6.1.3, trying to update now.
Are there any suggestions? Are there another timer-like objects which will let me create stable fast time reference?

#include <ti/sysbios/hal/Timer.h>

static Timer_Params timebaseTimerParams;

static Timer_Handle TimeBaseTmr_handle;

 

Void TimeBaseFunc(UArg arg0) //callback function

{

 PIN_setOutputValue(OutputsPinHandle, Board_LED1, !PIN_getOutputValue(Board_LED1)); //debug, to estimate how fast

}

...somewhere in main()...

if (TimeBaseTmr_handle == NULL)

{

Timer_Params_init (&timebaseTimerParams);

timebaseTimerParams.period=45; //45 uS

timebaseTimerParams.periodType=Timer_PeriodType_MICROSECS;

timebaseTimerParams.arg=1;

TimeBaseTmr_handle = Timer_create(Timer_ANY, TimeBaseFunc, &timebaseTimerParams, NULL);

}

if (TimeBaseTmr_handle == NULL) {System_abort("TimeBaseTmr create failed\n");}

Timer_start(TimeBaseTmr_handle);

 

 

  • Serge,

    The first thing that came to mind was that maybe in your standalone run the device is going fully into the Standby state where the general purpose timers are power gated.  [When the debugger is attached certain portions of the device are forced to stay on, so the device doesn’t power down as far as it does in a standalone run.  I don’t know if the timers are affected or not, this is just a guess, but it might explain this behavior(?)]  A transition into Standby will typically shut off the timers and they would not be restarted automatically.  But maybe in your app use case the timer is being restarted somehow(?).

    If you have power management enabled, can you try disabling it to see if that makes a difference and rules this out?  You can add this call to your app (for example in main()) to disable the Power driver's policy that typically runs in the idle loop:

        Power_disablePolicy();

    Does that make any difference?

    Also, I wonder why you are waking every 45usec.  That is 22KHz versus 3KHz.  Is this intentional?  If you are periodically interrupting at this rate the Power policy won't know about it, and may be repeatedly trying to transition into Standby, only to be quickly awoken before the low power state is reached.  Interrupts and thread scheduling are disabled during portions of the transition to/from Standby, so this could explain some jitter.  But not up to 1 second.  This can also be ruled out by disabling the policy.

    Thanks,
    Scott

  • Thank you, Scott, Power_disablePolicy() in main fix the problem. Even under debugger my interval became more stable, before it was sometimes delayed by few microseconds. And running standalone it works perfectly now, thanks again.

    I am using 45uS (22KHz) because of I am generating sine by points, so, in my case, I do around 7 points (22/3) approximation, using filtered out PWM signal, similar to digital-analog conversion, which CC1310 does not have. Actually, the signal I need to generate is not constant 3KHz, I need to do some sweep around 3Khz. Are there any other way how to generate sine, without using external dac?
  • OK, good, thanks for reporting back!

    One other option besides disabling the Power policy entirely is to declare a constraint to just prohibit Standby - and still allow the policy to choose either IDLE_PD or WFI to reduce consumption during idle time.  You can do this by replacing that call to Power_disablePolicy() with:

            #include <ti/drivers/power/PowerCC26XX.h>
            …
            Power_setConstraint(PowerCC26XX_SB_DISALLOW);

    And sorry, I don’t know of an alternative to producing a sine without the DAC.

    Regards,
    Scott

  • Thank you so much.