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.

TMS570LC4357: ADC reading not consistent

Part Number: TMS570LC4357
Other Parts Discussed in Thread: HALCOGEN

Hi,

I am using the PWMB event to trigger ADC readings, and I am having some question/issues.
The configuration I am using is the following (ADC/PWM example from HalCoGen):



I wrote this simple script to check the order of the data inside the data array after using the adcGetData function.

int main(void)
{
/* USER CODE BEGIN (3) */

    /* enable irq interrupt in */
    _enable_IRQ_interrupt_();

    adcInit();
    etpwmInit();
    adcStartConversion(adcREG1, adcGROUP0);
    etpwmStartTBCLK();

    while(1)
    {

        adcData_t data[16];
        for(volatile uint8_t ii; ii < 16; ii++)
        {
            data[ii].id = 0;
            data[ii].value = 0;
        }
        uint32 count;
        uint16 cmpA;

        count = adcGetData(adcREG1, adcGROUP0, data);

        volatile uint8_t tmp_brkpnt = 0;

        volatile uint32_t id = data[0].id;

        if(15 == id || 14 == id || 13 == id)
        {
            tmp_brkpnt = 1;
        }
    }

    while(1);

/* USER CODE END */

    return 0;
}

The data order inside the array seems to be inconsistent, as you can see on the following pictures:





Is the order not supposed to stay the same ? And is it normal to have two ADC readings of the same channel in a row ?

Also, it seems like I have to read the ADC buffer in order to get ADC readings. Indeed, when I am stopping the program in debug mode, if I change the input voltage of the pin, I need to read the ADC buffer twice in order to see the updated voltage.

Thank you !

  • The ADC conversion is performed in ascending order of the channel number. The conversion results are stored in the ADC result's RAM in order. The ADC RAM 

    To read the conversion result, please use the group conversion end interrupt or using the group threshold interrupt.