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.

CC1310 nortos time demo

Other Parts Discussed in Thread: CC1310

CC1310 NORTOS的 有定时器使用demo例程吗

  • 可以参考PWM例程,里面用到了timer,有nortos版:dev.ti.com/.../node
  • 要怎么设置才可以让定时器一直重复跑?

  •     GPTimerCC26XX_Params params;
        params.width          = GPT_CONFIG_32BIT;
        params.mode           = GPT_MODE_ONESHOT_UP;
        params.debugStallMode = GPTimerCC26XX_DEBUG_STALL_OFF;
        hTimer = GPTimerCC26XX_open(Board_GPTIMER0A, &params);
        if(hTimer == NULL)
        {
            while(1);
        }
     
        rxTimeoutVal = (SysCtrlClockGet()*3UL)/10UL - 1UL;
        GPTimerCC26XX_setLoadValue(hTimer, rxTimeoutVal);
        GPTimerCC26XX_registerInterrupt(hTimer, rxTimeoutCb, GPT_INT_TIMEOUT);
     GPTimerCC26XX_start(hTimer);

    void rxTimeoutCb(GPTimerCC26XX_Handle handle,
                     GPTimerCC26XX_IntMask interruptMask)
    {
        GPTimerCC26XX_setLoadValue(hTimer, rxTimeoutVal);
     PIN_setOutputValue(pinHandle, Board_PIN_LED2,!PIN_getOutputValue(Board_PIN_LED2));
     
     //GPTimerCC26XX_start(hTimer);
    }

    请问要怎么样设置才能使定时器重复进入中断?

    必须要在回调函数里面每次去 start吗?

  • 你要用GPTimer的什么模式?下面是我配置的下降沿中断检测的代码,每次检测到下降沿,就打印感叹号:

    /***** Includes *****/
    /* Standard C Libraries */
    #include <stdlib.h>
    #include <stdio.h>
    
    /* RTOS header files */
    #include <ti/sysbios/BIOS.h>
    #include <ti/sysbios/knl/Task.h>
    
    /* TI Drivers */
    #include <ti/drivers/rf/RF.h>
    #include <ti/drivers/PIN.h>
    #include <ti/drivers/pin/PINCC26XX.h>
    #include <ti/drivers/timer/GPTimerCC26XX.h>
    
    /* Driverlib Header files */
    #include DeviceFamily_constructPath(driverlib/rf_prop_mailbox.h)
    
    /* Board Header files */
    #include "Board.h"
    
    /***** Variable declarations *****/
    /* Pin driver handle */
    static PIN_Handle ledPinHandle;
    static PIN_State ledPinState;
    
    PIN_Config pinTable[] =
    {
        IOID_0 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_NEGEDGE  ,
        PIN_TERMINATE
    };
    
    GPTimerCC26XX_Handle hTimer0A;
    //static uint8_t counter = 0;
    
    void timerCallback0A(GPTimerCC26XX_Handle handle, GPTimerCC26XX_IntMask interruptMask)
    {
        printf("!\n");
    }
    
    /***** Function definitions *****/
    
    void *mainThread(void *arg0)
    {
        /* Open LED pins */
        ledPinHandle = PIN_open(&ledPinState, pinTable);
        if (ledPinHandle == NULL)
        {
            while(1);
        }
    
        GPTimerCC26XX_Params params0A;
        GPTimerCC26XX_Params_init(&params0A);
        params0A.width          = GPT_CONFIG_16BIT;
        params0A.mode           = GPT_MODE_EDGE_COUNT_UP;
        params0A.debugStallMode = GPTimerCC26XX_DEBUG_STALL_OFF;
        hTimer0A = GPTimerCC26XX_open(CC2640R2_LAUNCHXL_GPTIMER0A, &params0A);
        if(hTimer0A == NULL)
        {
            while(1);
        }
    
        GPTimerCC26XX_registerInterrupt(hTimer0A, timerCallback0A, GPT_INT_CAPTURE_MATCH);
    
        GPTimerCC26XX_PinMux pinMux = GPTimerCC26XX_getPinMux(hTimer0A);
        PINCC26XX_setMux(ledPinHandle, IOID_0, pinMux);
    
        GPTimerCC26XX_setCaptureEdge(hTimer0A, GPTimerCC26XX_NEG_EDGE);
        GPTimerCC26XX_setLoadValue(hTimer0A, 0xFFFFFF);
        GPTimerCC26XX_setMatchValue(hTimer0A, 1);
        GPTimerCC26XX_start(hTimer0A);
    
        while(1)
        {
            Task_sleep(BIOS_WAIT_FOREVER);
        }
    }
    
    

  • 我用的是GPT_INT_TIMEOUT
  • 找到问题了:
    params.mode = GPT_MODE_ONESHOT_UP;改为GPT_MODE_PERIODIC_UP 就可以了
  • 好的,例程里是单次计数,多次计数需要改为周期性计数模式