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/CC1350: Timer Interrupts are not working properly

Part Number: CC1350

Tool/software: TI-RTOS

Hello,

please help me to find out why the timer interrupts stop working when i add almost any function other than the initialization.

The timer is initialized and started as following:

    GPTimerCC26XX_Params params;

         GPTimerCC26XX_Params_init(&params);
         params.width          = GPT_CONFIG_32BIT;// GPT_CONFIG_16BIT;
         params.mode           = GPT_MODE_PERIODIC_UP;
         params.debugStallMode = GPTimerCC26XX_DEBUG_STALL_OFF;
         GPTimerCC26XX_Handle hTimer = GPTimerCC26XX_open(CC1350STK_GPTIMER0A, &params);

         xdc_runtime_Types_FreqHz  freq;
        BIOS_getCpuFreq(&freq);
        GPTimerCC26XX_Value loadVal = freq.lo - 1; //47999
        GPTimerCC26XX_setLoadValue(hTimer, loadVal);
        GPTimerCC26XX_registerInterrupt(hTimer, timerCallback, GPT_INT_MATCH);//GPT_INT_TIMEOUT
        GPTimerCC26XX_start(hTimer);


void timerCallback(GPTimerCC26XX_Handle handle, GPTimerCC26XX_IntMask interruptMask) {
    // interrupt callback code goes here. Minimize processing in interrupt.
    GPIO_toggle(Board_GPIO_LED1);

}

This snippet works correclty if nothing else added after  GPTimerCC26XX_start(hTimer);

but when i add a loop, sleep or almost any function after the mentioned code it stops doing interrupts (toggeling the LED)

Also when i call the UART_write function after the first snippet or inside the callback function, the timer ceases from working! 

why does this happen! the timer is already a hardware peripheral and should work independent from the rest of the code. it performs also hardware interrupts! 

Thank you in advance

  • Hi Majd,

    If you want to use the match interrupt you should also have to set the match value using setMatchValue. If you instead use GPT_INT_TIMEOUT you will get a periodic GPTimer tick using the code snippet you provided.
  • Hi M-W,

    I still want to use the periodic interrupt, (i want the timer toggle the led every second ). but in addition i want to add normally the rest of the program (like writing on UART how many interrupts happened). but when i add anything else to process, it seems that the timer stops /or the interrupt stops from executing.

    Best regards,
    Majd
  • If you want a periodic timer, you should use GPT_INT_TIMEOUT and not MATCH as you do (you can use match but then you would have to further alter the code). See the example usage for a periodic timer:

    dev.ti.com/.../_g_p_timer_c_c26_x_x_8h.html

    Regarding the program stopping when you do anything else, I would expect that this have to do with what you are doing. For example, how are you setting up UART when you are using it, are you sure you are not performing any blocking calls outside of task context (for example a blocking UART write inside a callback will hang the RTOS)?