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.

TMS570LS1227: Timeout for while loops in ADC

Part Number: TMS570LS1227
Other Parts Discussed in Thread: HALCOGEN,

Hi,

I have used HALCoGen tool to generate ADC driver code for TMS570LS1227.

For our requirement, we need to have a timeout for while loops.

Please could you suggest how to find out the approximate execution time for the following:

1)

/** - Wait for buffer initialization complete */
/*SAFETYMCUSW 28 D MR:NA <APPROVED> "Hardware status bit read check" */
while (((adcREG1->BNDEND & 0xFFFF0000U) >> 16U ) != 0U)
{
} /* Wait */

2)

/* ... wait and read the conversion count */
while((adcIsConversionComplete(adcREG1,adcGROUP1))==0);

Thanks and regards.

  • Hi Abrar,

    See my comments embedded below.

    1)

    /** - Wait for buffer initialization complete */
    /*SAFETYMCUSW 28 D MR:NA <APPROVED> "Hardware status bit read check" */
    while (((adcREG1->BNDEND & 0xFFFF0000U) >> 16U ) != 0U)
    {
    } /* Wait */

    >> HALCoGen generates code where the memory initialization is performed as part of the start-up routine. This includes all peripheral memories, including the two ADC RAMs. So the ADC auto-init is already completed by the time the code execution gets to this while loop. Following this typical code sequence, this loop does not take any time at all - the first read itself results in the execution getting out of the loop.

    2)

    /* ... wait and read the conversion count */
    while((adcIsConversionComplete(adcREG1,adcGROUP1))==0);

    >> The time a conversion is triggered to the time it completes is specified in the datasheet's ADC timings section. The sampling time is programmable by the application. The conversion time is either 12 ADCLK cycles or 10 ADCLK cycles depending on whether you are choosing 12-bit or 10-bit conversions. So the total wait time will be sampling time + conversion time for each channel. There are also 4 VCLK cycles between end of conversion of one channel and the start of sampling of the next channel in any group.

    Regards,
    Sunil