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.

set adc for TMS570

Other Parts Discussed in Thread: HALCOGEN

I am a rookie with this launchpad.

Recently I have been working with ADC, however problems occur.

1, It seems the ADC can only convert voltage below 2V or so. if I supply bigger voltage, it will be stuck in the code "while((adcIsConversionComplete(adcREG1,adcGROUP1))==0);"

I don't know why.

2, Is there a formula for the adc output value and the input voltage?

The adc outputs are around 3000, which confuses me.

Thanks

  • user4178447 said:

    1, It seems the ADC can only convert voltage below 2V or so. if I supply bigger voltage, it will be stuck in the code "while((adcIsConversionComplete(adcREG1,adcGROUP1))==0);"

    I don't know why.

    This doesn't make sense, you should recheck your setup.   The ADC can convert voltages in the range of ADREFHI to ADREFLO. 

    On a Launchpad this range is usually 3.3V to 0V. 

    2) Yes, it's included in the TRM MibADC Chapter - basically 0 to 4095 is conversion result scale and this is distributed across ADREFLO to ADREFHI in voltage.

    There might be an offset error and a nonlinearity but these are second order and I don't think you need to worry about them yet.   especially given the first issue.

  • Hi,

    how did you configure the ADC trigger? Is it software triggered?

    Regards, Szilárd

  • I use Halcogen to configure my ADC. Just like the embedded example in halcoGen.

    I don't know where is wrong.

  • It seems no problem. 

    My code is just a few necessary lines.

    adcInit();

    adcStartConversion(adcREG1,adcGROUP1);

    while((adcIsConversionComplete(adcREG1,adcGROUP1))==0);
    ch_count = adcGetData(adcREG1, adcGROUP1,&adc_data[0]);


    And my configuration imitates the example in HalCoGen.

    But the result is just limited less 2V.

  • Hi,

    you can use

    adcStartConversion(adcREG1,adcGROUP1);

    if software trigger is selected.

    As your HALCoGen printscreen shows, you are trying to use hardware trigger, actually rising edge of GIOB0 signal (I don't know it is your goal?)

    Select SW trigger, and use adcStartConversion() to initiate every single ADC measurement.

    Other thing: I couldn't see "channel selection" part of the configuration screen, but I assume that, there are more ADC channel enabled (tConversion 1.387us, tTotal 3.267 us), Make sure that you read the appropriate one.

    Regards, Szilárd

  • In the channel selection part, I select pin 0 and pin 1, but actually I don't understand the use of them. Would you please give me a brief explanation?
  • You have to enable that analog channel(s) (pins) what you want to convert to digital value.

    After the trigger signal (which can be software or hardver driven) a multiplexer start to switch over all enabled channel(s). AD coverter measues the channels and stores the digital value(s) and the channel ID(s) (if it is enabled) into the FIFO.

    FIFO size should have least equal or more than the number of enabled channels.

    After the conversion you can read out the digital value(s).

    For example, if you have enabled channel 3, 8, 9

    #define NUMBER_OF_ENABLED_CHANNEL 3
    int i;

    adcData_t Adc1Results[NUMBER_OF_ENABLED_CHANNEL];

    adcStartConversion(adcREG1, adcGROUP1);
    while(adcIsConversionComplete(adcREG1, adcGROUP1) == 0);
    adcGetData(adcREG1, adcGROUP1, Adc1Results);

    for(i=0;i<NUMBER_OF_ENABLED_CHANNEL;i++)
    {
    printf("Channel %d value: %d",  Adc1Results[i].id, Adc1Results[i].value);
    }

    Regards: Szilárd