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.

CCS/TM4C1294NCPDT: how to calculate ,how much time TM4C1294NCPDT libraries function is taking

Part Number: TM4C1294NCPDT

Tool/software: Code Composer Studio

Hii

My application is to read the adc at 6KHz sampling rate for 10 seconds when GPIO_WAKE will trigger and store that data in external Flash by using SPI then go to hibernation.

after coming from the hibernation again it will initialize the adc , timer and spi then it will go to read the adc channel.

I just want to how much time it will take to initialize the adc, timer and spi  and kindly suggest me ,how to calculate the time for every TM4C1294NCPDT libraries functions.

 

Thanks & Regards

Anamika

  • Hi Anamika,

     I think there are several ways to do this. Let me offer two here.

     1. Use the SysTick timer to calculate the time. Below is a simple example that you can also find in the Driver library user's guide.

    uint32_t ui32Value;
    //
    // Configure and enable the SysTick counter.
    //
    SysTickPeriodSet(1000);
    SysTickEnable();
    //
    // Delay for some time...
    //
    //
    // Read the current SysTick value.
    //
    ui32Value = SysTickValueGet();
    

    2. You can set a GPIO pin at the beginning of the library function and the clear the pin after the library function. Observe the time when the pin is high on the scope. 

  • Hii Charles,

    1. Use the SysTick timer to calculate the time. Below is a simple example that you can also find in the Driver library user's guide.

    As per step 1 , I have written below sample code to find how much time ADC_Init() is taking.

    void ADC_Init()
    {

    SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
    GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 );
    ADCSequenceConfigure(ADC0_BASE, 1, ADC_TRIGGER_PROCESSOR, 0);
    ADCSequenceStepConfigure(ADC0_BASE, 1, 0, ADC_CTL_CH3 | ADC_CTL_IE|ADC_CTL_END);
    ADCSequenceEnable(ADC0_BASE, 1);

    }

    /////////main///////////////

    {
    SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 120000000);

    SysTickPeriodSet(50);
    SysTickEnable();
    ADC_Init();
    ui32Value = SysTickValueGet();
    SysTickDisable();


    }

    When we are setting different period value in SysTickPeriodSet(50) then after adc initialization I am getting different value by using SysTickValueGet();

    suppose I have set SysTickPeriodSet(12) then I am getting ui32Value = 6;
    if I am setting SysTickPeriodSet(50) then I am getting ui32Value =20 ;
    and if I am setting SysTickPeriodSet(50) then I am getting ui32Value =395 ;

    Can you explain why this value is changing;

    2. You can set a GPIO pin at the beginning of the library function and the clear the pin after the library function. Observe the time when the pin is high on the scope

    GPIOPinWrite(GPIO_PORTN_BASE , GPIO_PIN_0, 1);
    ADC_Init();
    GPIOPinWrite(GPIO_PORTN_BASE , GPIO_PIN_0, 0);

    If I am trying the step 2 then i m not able to get the corresponding pin state pulses in CRO, but led is toggling with very low brightness.


    Thanks & Regards
    Anamika
  • Hi,
    I think you need to set the period to a larger value. When you set 12 it means the counter is preloaded with 12 and then count down. The ADC initialization will many more cycles than 12 to complete. During the ADC initialization the SysTick counter most likely has timeout multiple times and then reload the register. Why don't you try like a 1000 or some larger value before ADC initialization and read the counter and then calculate the difference between the preload value and the current counter value?

    In the GPIO case, it means the ADC_init takes very little time. You cannot rely on the LED. You need to use a scope to measure the pulse width. The ON time is too short to charge the LED.
  • Hii Charles

    Thanks for your quick response. By setting larger value in SysTickTimer, I am able to get the exact time taken by adc initialization.

    Thanks & Regards
    Anamika