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.

LAUNCHXL-CC26X2R1: about timer precision in cc26x2r

Guru 18625 points

Part Number: LAUNCHXL-CC26X2R1

Hi all,

 

I am creating a timer which toggles a GPIO output every 11 ms. In fact, it toggles 2 GPIO, which are always opposite (when one is 1, the other is 0, and the other way around). 

To do this, I used the Util_constructClock functions from SimpleBLEPeripheral. It sort of works, but I can often find pulses which are, for example 11.4 ms. The timer callback function only contains the two GPIO toggle instructions.

 

Thus, my question is twofold:

Question 1

Why Is this function failing to provide such timing? A 22 milliseconds period is NOT demanding at all, so I am surprised it performs that poorly. Maybe I should try to do it with low-level clockP calls like in this link (task 3) ? Is it gonna be more precise?

 

Question 2

How do I toggle 2 GPIO at the same time and not need 2 sequential calls one after the other? In MSP430, we used to be able to toggle with masks, so all pins switched together (p.e. P1OUT != 0x88). How can I do this in CC26X2R?

 

These are my software versions.

SDK v8.x

CCS v20

Launchpad CC26X2R1

 

Hope you had a nice holiday, have a nice day.

Will try to add a screenshot soon, although it won't add much.

  • Hello Kazola,

    Question 1

    Why Is this function failing to provide such timing? A 22 milliseconds period is NOT demanding at all, so I am surprised it performs that poorly. Maybe I should try to do it with low-level clockP calls like in this link (task 3) ? Is it gonna be more precise?

    As you pointed out, we could use a separate way of generating clocks, in the case of the CC26xx device I would recommend referring the example driver timerled, which shows how we create the normal timers. However I still believe that the Util_constructClock  should work, so we may need to look into this further. 

    Question 2

    How do I toggle 2 GPIO at the same time and not need 2 sequential calls one after the other? In MSP430, we used to be able to toggle with masks, so all pins switched together (p.e. P1OUT != 0x88). How can I do this in CC26X2R?

    We should be able to use the following structure to create a way of toggling (or writing to) a specific DIO, though we may still need two HWREG calls still:

    __STATIC_INLINE void
    GPIO_toggleDio( uint32_t dioNumber )
    {
        // Check the arguments.
        ASSERT( dioNumberLegal( dioNumber ));
    
        // Toggle the specified DIO.
        HWREG( GPIO_BASE + GPIO_O_DOUTTGL31_0 ) = ( 1 << dioNumber );
    }
    __STATIC_INLINE void
    GPIO_writeDio( uint32_t dioNumber, uint32_t value )
    {
        // Check the arguments.
        ASSERT( dioNumberLegal( dioNumber ));
        ASSERT(( value == 0 ) || ( value == 1 ));
    
        // Write 0 or 1 to the byte indexed DOUT map
        HWREGB( GPIO_BASE + dioNumber ) = value;
    }
    Thanks,
    Alex F
  • Hi Alex,

    Question 1

    I will check it we can use this timer library in the current SDK. Your example seems newer. I will try clockP first but thanks for providing an alternative.

    Question 2

    This is not what I asked. I wanted to toggle 2 GPIO at the same time.

  • Hello Kazola,

    Question 2:

    HWREGB(GPIO_BASE + GPIO_O_DOUT3_0 + 14) = HWREGB(GPIO_BASE + GPIO_O_DOUT3_0 + 15) = 1 & 0x01; //write GPIO on
    HWREGB(GPIO_BASE + GPIO_O_DOUT3_0 + 14) = HWREGB(GPIO_BASE + GPIO_O_DOUT3_0 + 15) = 0 & 0x01; //write GPIO off

    (HWREGB(GPIO_BASE + GPIO_O_DOUT3_0 + 14) = 1 & 0x01), (HWREGB(GPIO_BASE + GPIO_O_DOUT3_0 + 15) = 0 & 0x01) //for two different values

    Thanks,
    Alex F