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/CC2640R2F: TIMER

Other Parts Discussed in Thread: CC2640

Hi 

I am trying to enable TIMER0 and TIMER1 in cc2640 but  the Board_GPTIMER0A opened successfully and then I want open Board_GPTIMER3A but I cant open this.

can you please guide me how to do this and I also attached my code please guide me whats wrong with it 

            GPTimerCC26XX_Params_init(&params);
            params.width          = GPT_CONFIG_16BIT;
            params.mode           = GPT_MODE_PERIODIC_UP;
            params.debugStallMode = GPTimerCC26XX_DEBUG_STALL_OFF;
            hTimer = GPTimerCC26XX_open(Board_GPTIMER3A, &params);
            if(hTimer == NULL) {
              Log_error0("Failed to open GPTimer");
              Task_exit();
            }
            Types_FreqHz  freq;
            BIOS_getCpuFreq(&freq);
            GPTimerCC26XX_Value loadVal = freq.lo / 10 - 1; 
            GPTimerCC26XX_setLoadValue(hTimer, loadVal);
            GPTimerCC26XX_registerInterrupt(hTimer, timerCallback, GPT_INT_TIMEOUT);

        // Timer Configuration For Shutdown

              GPTimerCC26XX_Params paramsShutdown;
              GPTimerCC26XX_Params_init(&paramsShutdown);
              paramsShutdown.width          = GPT_CONFIG_16BIT;
              paramsShutdown.mode           = GPT_MODE_PERIODIC_UP;
              paramsShutdown.debugStallMode = GPTimerCC26XX_DEBUG_STALL_OFF;
              sTimer = GPTimerCC26XX_open(Board_GPTIMER0A, &paramsShutdown);
              if(sTimer == NULL) {
                Log_error0("Failed to open GPTimer");
                Task_exit();
              }
              Types_FreqHz  freqShutdown;
              BIOS_getCpuFreq(&freqShutdown);
              GPTimerCC26XX_Value loadValShutdown = freqShutdown.lo /100 - 1; 
              GPTimerCC26XX_setLoadValue(sTimer, loadValShutdown);
              GPTimerCC26XX_registerInterrupt(sTimer, timerCallback1, GPT_INT_TIMEOUT);

  • 1st GPTimerCC26XX_open is sucessfully opend the timer but the 2nd  GPTimerCC26XX_open cant open it returns null 

  • Hi,

    I could not reproduce your issue.

    In which context are you calling GPTimerCC26XX_open()?

    What is your SDK version?

    Have you tried to debug step by step inside the function GPTimerCC26XX_open() to see what could be wrong?

    If needed, here is the code I used:

    #include <ti/drivers/GPIO.h>
    #include <xdc/runtime/Types.h>
    #include <ti/sysbios/knl/Task.h>
    #include <ti/drivers/timer/GPTimerCC26XX.h>
    #include <ti/sysbios/BIOS.h>


    GPTimerCC26XX_Handle hTimer; GPTimerCC26XX_Handle sTimer; void timerCallback(GPTimerCC26XX_Handle handle, GPTimerCC26XX_IntMask interruptMask) { GPTimerCC26XX_stop(hTimer); GPIO_toggle(Board_GPIO_LED0); GPTimerCC26XX_start(hTimer); } void timerCallback1(GPTimerCC26XX_Handle handle, GPTimerCC26XX_IntMask interruptMask) { GPTimerCC26XX_stop(sTimer); GPIO_toggle(Board_GPIO_LED1); GPTimerCC26XX_start(sTimer); } /* * ======== mainThread ======== */ void *mainThread(void *arg0) { /* Call driver init functions. */ GPIO_init(); GPTimerCC26XX_Params params; GPTimerCC26XX_Params_init(&params); params.width = GPT_CONFIG_16BIT; params.mode = GPT_MODE_PERIODIC_UP; params.debugStallMode = GPTimerCC26XX_DEBUG_STALL_OFF; hTimer = GPTimerCC26XX_open(Board_GPTIMER3A, &params); if(hTimer == NULL) { //Log_error0("Failed to open GPTimer"); Task_exit(); } Types_FreqHz freq; BIOS_getCpuFreq(&freq); GPTimerCC26XX_Value loadVal = freq.lo / 10 - 1; GPTimerCC26XX_setLoadValue(hTimer, loadVal); GPTimerCC26XX_registerInterrupt(hTimer, timerCallback, GPT_INT_TIMEOUT); GPTimerCC26XX_start(hTimer); // Timer Configuration For Shutdown GPTimerCC26XX_Params paramsShutdown; GPTimerCC26XX_Params_init(&paramsShutdown); paramsShutdown.width = GPT_CONFIG_16BIT; paramsShutdown.mode = GPT_MODE_PERIODIC_UP; paramsShutdown.debugStallMode = GPTimerCC26XX_DEBUG_STALL_OFF; sTimer = GPTimerCC26XX_open(Board_GPTIMER0A, &paramsShutdown); if(sTimer == NULL) { //Log_error0("Failed to open GPTimer"); Task_exit(); } Types_FreqHz freqShutdown; BIOS_getCpuFreq(&freqShutdown); GPTimerCC26XX_Value loadValShutdown = freqShutdown.lo /100 - 1; GPTimerCC26XX_setLoadValue(sTimer, loadValShutdown); GPTimerCC26XX_registerInterrupt(sTimer, timerCallback1, GPT_INT_TIMEOUT); GPTimerCC26XX_start(sTimer); while(1); return (NULL); }

    Best regards,

  • Thanks For The Response 

    So i am using Simple Link SDK - simplelink_cc2640r2_sdk_3_10_00_15

    I am Calling GPTimerCC26XX_open()  form Project Zero_init () routine of Project Zero Example Project ( Imported from Resource Viewer ) 

    But in my case 

    hTimer = GPTimerCC26XX_open(Board_GPTIMER3A, &params); opened Successfully but after execution of that I also called the 2nd Timer Open Routine
    sTimer = GPTimerCC26XX_open(Board_GPTIMER0A, &paramsShutdown); In the Same way like You, but every time GPTimerCC26XX_open() for sTimer returns NULL

    Thanks For Your Support


  • Please check that this timer is not already used elsewhere and choose a different timer if this is the case.

    Regards,