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.

TI-RTOS CC26xx high-resolution timer and PWM

Other Parts Discussed in Thread: CC2650, SYSBIOS

Hi team,

 

I have a customer that is looking to find the proper approach to manipulate high-resolution timer and PWM on CC26XX with BLE STACK on TI-RTOS level.

 

 

Their feedback was:

 

I was using driverlib/timer.h to do some basic testing. Then I found there are PWM.h and TIMER.h in drivers lib. Which are in OS level.

 

From this post: https://e2e.ti.com/support/wireless_connectivity/bluetooth_low_energy/f/538/p/405132/1435673#1435673

 

It used driverlib/timer.h + Power_setConstraint(Power_SB_DISALLOW);. But it seems not working in simple_peripheral with 2.2 BLE stack.

 

I tried to use OS level library, drivers/PWM.h and TIMER.h. But it seems I didn't find the right way.

 

 

Thanks in advance for the help,

Billy

  • Hi Billy,
    What version of TI-RTOS are they using? The PWM driver was added to TI-RTOS in version 2.20.00.06. If they have that version, there is a PWM example they can look at.
    Best regards,
    Janet
  • Thanks for the super quick response Janet. I see that in v2.20, not in 2.16 you’re right. What about the HR timer?

    Thanks,
    Billy
  • Hi Billy,

    The PWM example uses the GP timers.  Here is the PWM configuration from the <board>.c file:

    /* PWM configuration, one per PWM output.   */
    PWMTimerCC26XX_HwAttrs pwmtimerCC26xxHWAttrs[CC2650DK_7ID_PWMCOUNT] = {
        { .pwmPin = Board_PWMPIN0, .gpTimerUnit = Board_GPTIMER0A },
        { .pwmPin = Board_PWMPIN1, .gpTimerUnit = Board_GPTIMER0B },
        { .pwmPin = Board_PWMPIN2, .gpTimerUnit = Board_GPTIMER1A },
        { .pwmPin = Board_PWMPIN3, .gpTimerUnit = Board_GPTIMER1B },
        { .pwmPin = Board_PWMPIN4, .gpTimerUnit = Board_GPTIMER2A },
        { .pwmPin = Board_PWMPIN5, .gpTimerUnit = Board_GPTIMER2B },
        { .pwmPin = Board_PWMPIN6, .gpTimerUnit = Board_GPTIMER3A },
        { .pwmPin = Board_PWMPIN7, .gpTimerUnit = Board_GPTIMER3B },
    };

    Best regards,

    Janet

  • Hi Janet,


    They like the PWM example but still are after anything from us using a high res timer. Here is the feedback:


    Right now, rtos provided an application layer clock module. Which only supports 10us resolution.

    I want to apply a higher resolution timer with interrupt function which has at least 1us resolution.

    I tried to use power constraint + 26XX ware level APIs. But the chip will get stuck at some places where calls these lower layer APIs.

    Is there any way to do a higher resolution timer in TI-RTOS?



    Thanks,
    Billy
  • Hi Billy,

    There isn't a timer example shipped with TI-RTOS for CC2650, but I can give you some code from a timer test.  They can use the BIOS lm4 timer, which is running at 48MHz, so that would give them the 1us resolution.

    Here is how they can create the timer in their c code:

        #include <ti/sysbios/family/arm/lm4/Timer.h>

        Timer_Params prms;

        Timer_Params_init(&prms);

        prms.arg = 1;  // Whatever argument they want
        prms.period = 1;
        prms.runMode = Timer_RunMode_ONESHOT;
        prms.periodType = Timer_PeriodType_MICROSECS;
        Timer_create(Timer_ANY, myIsr, &prms, NULL);

    They would need to exclude timers used by PWM from the lm4 Timer module.  They can do this by configuring the 'availMask' in the .cfg file, for example:

        Timer = xdc.useModule('ti.sysbios.family.arm.lm4.Timer');
        Timer.availMask = 0xE; // Exclude timer 0

    In this example, you would need to take Timer 0 out of the PWM config in the <board>.c file.

    Best regards,

    Janet

  • Thanks a lot for all the help Janet! They are moving along. Hopefully this is the last piece of it, they had explained an odd thing they are seeing:

    This one works as the SYSBIOS manual described, but one thing wired is it can only run under debugging mode. Once I stop debugging and the board was reset to run again, it can never get into the interrupt callback function.


    Thanks,
    Billy
  • Hi Billy,

    Which interrupt callback function are you referring to, the Timer interrupt?

    Thanks,

    Janet

  • FYI: Starting with TI RTOS 2.20, there is a dedicated GPTimer driver and PWM driver for the CC26 / CC13XX.
    The GPTimer driver is found at the default install path C:\ti\tirtos_cc13xx_cc26xx_2_20_00_06\products\tidrivers_cc13xx_cc26xx_2_20_00_08\packages\ti\drivers\timer

    The LM4 Timer module should not be used, this is a kernel Timer module from the Stellaris LM4 devices which has the same GPTimer as CC26/CC13XX.

    Regards,
    Svend