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.

CC2640R2F GPTimer怎么修改定时时间

Expert 2290 points

Other Parts Discussed in Thread: CC2640R2F

CC2640R2F GPTimer在运行时怎么修改定时时间, 有函数接口吗?

  • 您可以在下面的链接找到如何使用GPT timer

    C:/ti/simplelink_cc2640r2_sdk/docs/tidrivers/doxygen/html/_g_p_timer_c_c26_x_x_8h.html


    以下代码是每1ms产生一个中断

    GPTimerCC26XX_Handle hTimer;
    void timerCallback(GPTimerCC26XX_Handle handle, GPTimerCC26XX_IntMask interruptMask) {
        // interrupt callback code goes here. Minimize processing in interrupt.
    }
    void taskFxn(UArg a0, UArg a1) {
      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(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);
      }
    }