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/LAUNCHXL-CC1310: CC1310

Part Number: LAUNCHXL-CC1310
Other Parts Discussed in Thread: SYSBIOS, CC1310, CC1020

Tool/software: TI-RTOS

Hi, I´m working with: simplelink_cc13x0_sdk_2_10_00_36.

I need to use a timer to count rising edge pulses, how can I do it?, do you have any example, please?

I read about GPTimerCC26XX.h, but when I add these header 

#include <ti/sysbios/family/arm/cc26xx/Power.h>
#include <ti/sysbios/family/arm/cc26xx/PowerCC2650.h>

the compiler don't find it.

Thanks

  • To include the for example the GPTimerCC26XX.h you need to do the following:

    #include <ti/drivers/timer/GPTimerCC26XX.h>

    If you do a search on the forum for GPTimer you will find several examples. One is found here:

    e2e.ti.com/.../2449517

    BR

    Siri
  • Hi, thanks for your help.

    I wrote these lines:

    #include <ti/drivers/timer/GPTimerCC26XX.h>
    
    GPTimerCC26XX_Handle hTimer;
    
    void taskFxn(uintptr_t a0, uintptr_t a1) {
        GPTimerCC26XX_Params params;
        GPTimerCC26XX_Params_init(&params);
        params.width          = GPT_CONFIG_16BIT;
        params.mode           = GPT_MODE_EDGE_COUNT_UP;
        params.debugStallMode = GPTimerCC26XX_DEBUG_STALL_OFF;
        hTimer = GPTimerCC26XX_open(CC1310_LAUNCHXL_GPTIMER0A, &params);
        if(hTimer == NULL) {
            while(1);
        }
    
        xdc_runtime_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);
        }
    }

    I want count pulses of pulse meter and I need get an interrupt when the timer count overflows, is necessary put these lines:
    xdc_runtime_Types_FreqHz freq;
    BIOS_getCpuFreq(&freq);

    I think put, for initial value:

    GPTimerCC26XX_setLoadValue(hTimer, 0);

    But, what should I put for enable the interrupt for GPT_MODE_EDGE_COUNT_UP? in:

    GPTimerCC26XX_registerInterrupt(hTimer, timerCallback, xxxxxxxxx);

    Last, how can I set the timer prescaler to 1:1, and using some pin as input for timer external counter, please?

    Thanks

  • The code below can be tested on our LPs and will give you an interrupt everytime you have pushed the BTN-1 5 times

    GPTimerCC26XX_setMatchValue(hTimer0A, 5);

    /***** Includes *****/
    /* Standard C Libraries */
    #include <stdlib.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[] =
    {
        Board_PIN_LED1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
        Board_PIN_LED2 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
        Board_PIN_BUTTON0 | 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)
    {
        counter += 5;
    }
    
    /***** 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(CC1310_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, Board_PIN_BUTTON0, pinMux);
    
        GPTimerCC26XX_setCaptureEdge(hTimer0A, GPTimerCC26XX_NEG_EDGE);
        GPTimerCC26XX_setLoadValue(hTimer0A, 0xFFFFFF);
        GPTimerCC26XX_setMatchValue(hTimer0A, 5);
        GPTimerCC26XX_start(hTimer0A);
    
        while(1)
        {
            Task_sleep(BIOS_WAIT_FOREVER);
        }
    }

    BR

    Siri

  • Hello, thanks for your help. I test your code in my cc1310 launchpad and it's ok.

    I have doubts, for example: GPTimerCC26XX_setMatchValue(hTimer0A, 5); means that interrupt is when the accumulator register for timer is equal to 5,I undestant and I test this function ok.

    Could you tell me what does GPTimerCC26XX_setLoadValue(hTimer0A, 0xFFFFFF); do?,I tested with different values and I think that is the maximum value for the accumulator register, why when the accumulator reach the value go to 0, is that correct?

    In my project I'm getting pulses of vehicle odometer and  I need to set interrupt when the counter reach the value of pulses per kilometer (PPK) and in this interrupt I need to set the accumulator register to 0, right now I need to get one more pulse to reset the accumulator register, How can I set the accumulator register to 0?, can I access this register directly?

    Do you have more documentation about CC1310:

    http://www.ti.com/lit/ug/swcu117h/swcu117h.pdf 

    http://www.ti.com/lit/ds/symlink/cc1310.pdf 

    Thanks.

  • I do not actually think that the GPTimerCC26XX_setLoadValue(hTimer0A, 0xFFFFFF); is necessary in up-count mode. The timer starts on 0 and count until you reach the match value. However, it seems that after you reach the match value (TAM = 0x5) the TAM register is not reset to 0 before the next edge. That means that the first time you need 5 edges before you get the interrupt, but after that you need 6 edges.

    You do not manually have to reset the TAM register.

    In addition to the TRM, you should also look at the driver documentation found here:

    http://dev.ti.com/tirex/#/?link=Software%2FSimpleLink%20CC13x0%20SDK%2FDocuments%2FDrivers%2FTI%20Drivers%20Runtime%20APIs

    Siri

  • Thanks for your help, 

    Do you have any method to estimate THREADSTACKSIZE?, We have old equipment with cc1020 chip (433MHz), can I communicate cc1310 with these chips?, do you have a link with reference desing CC1310 - 433MHz, please?

  • If CC1310 can communicate or not with the CC1020 depends on how the CC1020 is configured. Remember that CC1310 is not a narrowband device, meaning that you will have troubled with regulation (ARIB T-67 og ETSI EN300 220) when using 12.5 and 25 kHz channels.
    A reference design for CC1310 at 433 MHz is found here:
    http://www.ti.com/lit/swra528
    Unfortunately I cannot answer your questions regarding THREADSTACKSIZE and I recommend that you post this question in a separate post.

    Siri
  • Hello, do you have a reference desing without range extension, please?

  • Hello, I found this schematic for 433MHz. Is this correct, please?

    Thanks4278.CC13xxEM-7XD-4251_schematic_1_2_0.pdf

  • If this is the same as referred to in this post:

    e2e.ti.com/.../583471

    it should be OK to use.

    BR

    Siri
  • Thanks for your help.