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.

CC2652PSIP: Timer Edge Capture for Counting

Part Number: CC2652PSIP

Tool/software:

Hi,  

I am attempting to use a gp timer in edge capture mode so I can count digital pulses.  Is there an example that I can reference to do this? 

  • Hello Chris,

    We may not have an exact example here, but we can try modifying the period example to use edge capture:

     (reference the SDK documentation by pressing the "GPTimer Driver" hyperlink) 

    GPTimerCC26XX_Handle hTimer;
    void timerCallback(GPTimerCC26XX_Handle handle, GPTimerCC26XX_IntMask interruptMask) {
        // interrupt callback code goes here. Minimize processing in interrupt.
    }
    void taskFxn(uintptr_t a0, uintptr_t a1) {
      GPTimerCC26XX_Params params;
      GPTimerCC26XX_Params_init(&params);
      params.width          = GPT_CONFIG_16BIT;
      params.mode           = GPT_MODE_PERIODIC;
      params.direction      = GPTimerCC26XX_DIRECTION_UP;
      params.debugStallMode = GPTimerCC26XX_DEBUG_STALL_OFF;
      hTimer = GPTimerCC26XX_open(CC2650_GPTIMER0A, &params);
      if(hTimer == NULL) {
        Log_error0("Failed to open GPTimer");
        Task_exit();
      }
      Types_FreqHz  freq;
      BIOS_getCpuFreq(&freq);
      GPTimerCC26XX_Value loadVal = freq.lo / 1000 - 1; //47999
      GPTimerCC26XX_setLoadValue(hTimer, loadVal);
      GPTimerCC26XX_registerInterrupt(hTimer, timerCallback, GPT_INT_TIMEOUT);
      GPTimerCC26XX_start(hTimer);
      while(1) {
        Task_sleep(BIOS_WAIT_FOREVER);
      }
    }

    Thanks,
    Alex F