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.

CC3200MOD: utilsdelay is not giving precise delay in CC3200 & CC3220SF

Part Number: CC3200MOD
Other Parts Discussed in Thread: CC3200, CC3220SF

Hi,

i am using UtilsDelay from utils.c in the SDK driverlib for microsecond delay.

Assembly code used for UtilsDelay(unsigned long ulCount)

// For CCS implement this function in pure assembly.  This prevents the TI

// compiler from doing funny things with the optimizer.

//

#if defined(ccs)

    __asm("    .sect \".text:UtilsDelay\"\n"

          "    .clink\n"

          "    .thumbfunc UtilsDelay\n"

          "    .thumb\n"

          "    .global UtilsDelay\n"

          "UtilsDelay:\n"

          "    subs r0, #1\n"               

          "    bne.n UtilsDelay\n"          

          "    bx lr\n");

#endif

As per documentation UtilsDelay(unsigned long ulCount) funtion takes 3 clock cycle to execute.

in CC3200 below calculations for 10 us delay getting 20 us delay which is 2X times greater then expected

ulCount = 10 * 80/3 

Expected: 10 us delay

output: 20 us delay

in CC3220SF below calculations for 10 us delay getting 40 us delay which is 4X times greater then expected

ulCount = 10 * 80/3 

Expected: 10 us delay

output: 40 us delay

My questions:

1. Why i am seeing 2X times greater delay in CC3200 and 4x times greater delay in CC3220SF

Thanks,

            Cornelius S

  • Hi Cornelius,

    How are you testing the delay?

    Best regards,

    Sarah

  • Hi Sarah,

                   I am using GPIO ON and OFF to measure Delay

                   GPIO_ON

                    UtilsDelay

                  GPIO_OFF

    Thanks,

                Cornelius S

  • Hi Cornelius S,

    I'm assuming you are using the demo gpio_if API for CC3200 (GPIO_IF_LedOn) and TI Drivers API for CC3220 (GPIO_write or GPIO_toggle)? Keep in mind these APIs will take additional clock cycles to execute. Especially on CC3220, the TI Drivers APIs are an abstraction layer over the device-specific driverlib.

    The driverlib API is GPIOPinWrite. If you use this API directly, do you get better results?

    // For CC3200
    #include "hw_types.h"
    #include "hw_memmap.h"
    #include "pin.h"
    #include "gpio.h"
    
    // For CC3220 
    #include "ti/devices/cc32xx/inc/hw_types.h"
    #include "ti/devices/cc32xx/inc/hw_memmap.h"
    #include "ti/devices/cc32xx/driverlib/pin.h"
    #include "ti/devices/cc32xx/driverlib/gpio.h"
    
    GPIOPinWrite(GPIOA1_BASE, PIN_64, 0);

    Writing to the GPIO peripheral from the register-level should give a more accurate delay. See the CC3200 TRM and CC3220 TRM.

    Best regards,

    Sarah