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.

Multi ADC Problem

Other Parts Discussed in Thread: TMS570LS3137, HALCOGEN

I have a TMS570LS3137 HDK dev. kit and usb stick.

I want to read more then one adc result.

I set the halcogen setting. I selected group 1. Then selected 2 channels.

I can manage one adc reading. if this is more than one, i will stucked.

For example a one adc reading;

void main(void)

adcData_t adc_data;
adcData_t *adc_data_ptr = &adc_data;

adcInit();
while(1)
{
adcStartConversion(adcREG1, 1U);
while(!adcIsConversionComplete(adcREG1, 1U));

adc_data_ptr->id = 9U;
adcGetData(adcREG1, 1U, adc_data_ptr);
valuex = (unsigned int)adc_data_ptr->value

}

This is work for one adc reading. I want to do 2 or more adc reading on one adc module. Only adc group1.

I added this code to upper codes.

adc_data_ptr->id = 8U;
adcGetData(adcREG1, 1U, adc_data_ptr);
valuey = (unsigned int)adc_data_ptr->value

Then i cant read this channels rightly. The readed value is 65182, something like that. And both channel's result is the same 65000...

I need help for one more adc reading..

Best regards...

  • Hi,

    I will take a look and get back to you.

  • Thanks, i will wait...

  • Hi,

    I've checked your code and did some modifications.

    The function adcGetData() checks how many channel are enabled for the given group.
    The 3rd argument has to be a pointer to an array with dimension that matches the number of enabled channel (adcData_t adc_data[2];)
    adcGetData() also returns the number of data read from the given group. (adcGROUP1).

    The id is only valid if the check box "Enable Channel Id in Conversion Results is checked. (Otherwise id will always be 0).

    As reference, here is the modified code I'm using.

    Note: Channel 8 is the light sensor and channel 9 is the temperature sensor on the HDK and USB stick for TMS570LS3137.

    void main(void)
    {
    /* USER CODE BEGIN (3) */
        adcData_t adc_data[2];
        uint32_t ch_count=0;
        uint32_t id    = 0;
        uint32_t value = 0;
        uint32_t i;


        adcInit();
        while(1)
        {
         adcStartConversion(adcREG1, adcGROUP1);
         while(!adcIsConversionComplete(adcREG1, adcGROUP1));

         ch_count = adcGetData(adcREG1, adcGROUP1, adc_data);

         for (i=0;i<ch_count;i++)
         {
          value = adc_data[i].value;
          id    = adc_data[i].id;
         }
        }
    /* USER CODE END */
    }