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.

CC1352P: Timer calling callback much faster than expected.

Part Number: CC1352P
Other Parts Discussed in Thread: SYSCONFIG

I am working on a custom board that has a methane sensor that needs to be heated for n seconds before an accurate reading can be taken. To do this I have a 1 second timer running. After the callback has been hit n times a flag is set and readings can be considered valid readings. The issues I am having is that the callback is being called much faster than every 1 second. This timing is a critical part of the system.

The timer is set as a 32 bit timer in the .syscfg. My understanding is that the largest time a 32 bit timer can do is just over 89 seconds (2^32 ticks / 48MHz), so I'm not entirely sure what the issue is. The timer period is well under the limit of the timer.

Initialization of timer:

Timer_Params methaneTimerParams;
Timer_Params_init(&methaneTimerParams);

//Set the timer parameters
methaneTimerParams.period = 1000000;    //1 second period
methaneTimerParams.periodUnits = Timer_PERIOD_US;
methaneTimerParams.timerMode = Timer_CONTINUOUS_CALLBACK;
methaneTimerParams.timerCallback = HeaterTimeoutCb;

Trying to debug this I put "uint32_t testCount = Timer_getCount(handle);" at the beginning of the callback function. This was giving wildly inconsistent values, ranging from a few hundred to tens of millions. I would expect this to be a consistent value as it is the first line of the callback function.

Timer callback:

void HeaterTimeoutCb
(
        Timer_Handle handle,
        int_fast16_t status
)
{
    uint32_t testCount = Timer_getCount(handle);
    timerSeconds.secondsWaited++;
    if (timerSeconds.secondsToWait <= timerSeconds.secondsWaited)
    {
        heaterWarmingComplete = true;
        Timer_stop(handle);
    }
}

There is another timer in this project that controls LED blinking that has the same exact parameters except that its mode is Timer_ONESHOT_CALLBACK. This timer works as expected with the callback being called once a second. I swapped the timer peripheral between the two timers and they still both had their same behaviors.

I am at a loss as to why these two timers behave so differently and why the heating timer is not calling it's callback at the right interval. What could be causing this behavior? Is there something about the Timer_CONTINUOUS_CALLBACK mode that is causing the callback to be called faster than once a second, or is there a deeper issue?

Tim

  • Hi Tim,

    The timerled example in the SDK uses the timer in the continuous callback mode. So, I don't believe that there is an inherent issue with the mode. Instead of using in the debug mode to capture the count value, is it possible for you to toggle a GPIO in the timer callback and capture it with a logic analyzer? This is to get rid of delays added by the debugger.

    Also can you tell us what the interrupt priorities you are using for the timers? This is set in sysconfig.

    Regards,

    Sid 

  • Later reply here, but putting the breakpoint in the callback was indeed causing the issues. I changed my test code a little to check the state of the flag in the callback at a couple different points and then looked at all the data with a single breakpoint at the end it behaved as expected.