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.

AM2434: Optimize ADC Data Update Function Execution Time

Part Number: AM2434

Tool/software:

Hi TI Experts,

Customer is working on AM24x SDK9.2, by following the below thread the functionality of ADC voltage sampling is working normal now.

https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/1424959/am2432-fifo-words-in-fifo-reading-is-abnormal-when-using-adc-voltage-sampling

However, customer found their function "bsp_AdcValueUpdata" shown below execute time is 55.4us.

 It is too large for the called interrupt function frequency(8K). It is meaning that the ADC update function has occupied 44% of the entire task. Like the followed pic: 

Customer may have the following two questions may need your support.

1) Why does this execution method have such a large overhead, and specifically where is the cost incurred?

2) Is there any plan to optimize this overhead and reduce the time to less than 10us?

Thanks,

Kevin

  • Hello Kevin,

    I am looking at your queries and you may expect reply in one or two days.

    Regards,

    Anil.

  • Hello Kevin,

    Can you please confirm if the above measurement (55.4usec) was done in release mode or debug mode ?

    I can give some suggestions to reduce the overhead, but please provide the above input.

    Regards,

    Anil.

  • Hi Anil,

    Thanks for your reply.

    Customer used the release mode.

    Thanks,

    Kevin

  • Hello Kevin,

    Please try my suggestions below and confirm how much time is reduced.

    Method 1 : 

    In current customer implementation, we can't change time from ADC start to till ADC extraction.

    Now, to reduce overhead, try the steps below.

    After ADC extracts data, we called ADC stop. So, instead of calling the ADC stop API,

    Just stop the ADC and wait for the ADC to idle.

    code : 

    /* Stop ADC */
    ADCStart(baseAddr, FALSE);
    
    /* Wait for FSM to go IDLE */
    ADCGetSequencerStatus(baseAddr, &status);
    while ((ADC_ADCSTAT_FSM_BUSY_IDLE != status.fsmBusy) &&
    ADC_ADCSTAT_STEP_ID_IDLE != status.stepId)
    {
    ADCGetSequencerStatus(baseAddr, &status);
    }

    Next, instead of calling ADCconfig API, just enable steps.

    code : 

        /* Step enable */
        for(chCnt = 0U; chCnt < APP_ADC_NUM_CH; chCnt++)
        {
            adcStep = ADC_STEP_1 + chCnt;   /* Step -> Channel one to one mapped */
            ADCStepEnable(baseAddr, adcStep, TRUE);
        }

    Later, start the ADC.

    Method 2 : 

    Entire ADC functionality will be divided into 3 parts. ADC start, ADC stop and ADC processing.

    Now, you can implement 3 ADC states. ADC_START, ADC_PROCESSING and ADC_STOP.

    case ADC_START : Start ADC 

    case ADC_PROCESSING : 

    Here, you need to poll  if ADC conversion is completed or not.

    If ADC conversion is completed, then extracting the ADC data and then move to the next state ADC stop.

    case ADC_STOP : Stop the ADC, enable Steps and then move to ADC start state.

    Method3 : 

    Combine Method 1 and Method 2.

    If user still wants to reduce the overhead further then they should go with the ISR method .

    Method 4 : 

    ISR Method : 

    In the task, they need to start the ADC.

    In the ISR routine , users need to extract the ADC data. Again, users need to start the ADC based on the previous conversion completion status in the task.

    And other than these  methods, there are no methods to reduce further overhead.

    Regards,

    Anil.

  • Hi Anil,

    Appreciate your great support, it is working on customer side, let me describe the details below.

        1) Used the method1:

        Shorten the task of the bspADCStop() interface while reducing the time and steps required for the ADCConfig task.

    The actual ADC update time is around 8us, but in reality it can be interrupted by TaskC, resulting in a time of around 30us.

    2) Combining method1 and method2:

    Assuming there are no interruptions, the current execution time for ADC is around 5 microseconds per cycle, with fluctuations of approximately 3.5 to 4.5 microseconds.

    Finally, It currently can match customer's requirement.

    Thanks,

    Kevin