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.

ADC does't work on a simple example

Other Parts Discussed in Thread: HALCOGEN, TMS570LS1224

Hello to everybody, 

I was just doing the most simple example for an ADC on the Launchpad TMS570LS1224 but i couldn't make it work. I am using CCS 6.1.1 and HalCoGen 04.05.01. 

The exmple is just meant to take data from an ADC and show it some LEDs.

The configuration on HalCogen is as follow:

And the code is as simple as this (in sys_main.c):

/* USER CODE BEGIN (1) */
#include "gio.h"
#include "adc.h"
/* USER CODE END */

/* USER CODE BEGIN (2) */
adcData_t adc_data;
/* USER CODE END */

void main(void)
{
/* USER CODE BEGIN (3) */
gioInit();
adcInit();
adcStartConversion(adcREG1, adcGROUP0);
while(1)
{

while(adcIsConversionComplete(adcREG1, adcGROUP0)==0){};
adcGetData(adcREG1, adcGROUP0, &adc_data);

gioSetBit(gioPORTA, 0, 1);
gioSetBit(gioPORTA, 1, adc_data.value<<1);
gioSetBit(gioPORTA, 2, adc_data.value<<2);
gioSetBit(gioPORTA, 1, adc_data.value<<3);
gioSetBit(gioPORTA, 2, adc_data.value<<4);
gioSetBit(gioPORTA, 5, adc_data.value<<5);
gioSetBit(gioPORTA, 6, adc_data.value<<6);
gioSetBit(gioPORTA, 7, adc_data.value<<7);

}
/* USER CODE END */
}

The thing is, i can't get a single value of the adc_data despite i change the voltage at the input. It even can´t get throught the while(adcIsConversionComplete(adcREG1, adcGROUP0)==0){}; (i know that because the first led is not on). For this simple example i looked at most of the registers but i can't make it work. 

All the files are here. 8883.TMS570LS1224_adc_memory.rar

I will appreciate if someone can tell me where am i doing the foolish mistake.

Best Regards

Francisco Dumont

  • I think you are activating a conversion group "ADC 1 Group Event" and the right thing would turn into "ADC Group 1", but in its code should replace
    adcStartConversion (adcREG1, adcGROUP1);
    I'm not sure if "adcGROUP0" exists in the version of Hercules
    Luck!
  • ADC group 0 is the name used for the "Event" group, which is a hardware event-triggered conversion group. The line in source code:

    adcStartConversion(adcREG1, adcGROUP0);

    sets up the channels selected for conversion in group0. The ADC is still waiting for the selected event to occur so that the group0 conversions can start. The default trigger event is a falling edge on the AD1EVT pin. You can even generate this falling edge by configuring the AD1EVT pin as an output pin and then driving it high followed by a low. This will start the conversions. Then you can poll for the conversion-complete flag to be set.
  • Alternatively, you can switch over to using group1 for the conversions. This group is software-triggered by default and the conversions can be started by calling adcStartConversion(adcREG1, adcGROUP1).
  • Hi Francessca and Sunil,
    thank you for the replies.
    Sunil you were right, the trigger event was what i forgot.
    thank you

    Best Regards
    Francisco Dumont