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 Self-Test und Calibration

Part Number: TMDX570LC43HDK
Other Parts Discussed in Thread: HALCOGEN

Hello,

I am using the Hercules TMDX570LC43HDK for the first time. I have done some tutorials , especially how to use ADC for onboard integrated light and temperature sensors. I have noticed, that my calculated ADC value with calculator, has not the same value as the ADC value, calculated by MCU. To proof that, I took 5V from TP23 and connected it to PIN7 from AD1IN. As result I got ADC value of 4095 = 4.999V. Same result when I connect PIN7 from AD1IN to GND, ADC value 0001 = 0.001220703 mV. At the end i took two 10k resitors an built a voltage divider. So the ADC value has to be 2048 = 2.5V but the result was 2.20 V. I think I have to calibrate the ADC but I dont know how to do that. I found "Technical Reference Manual TMS570LC43x 16/32-Bit RISC Flash
Microcontroller" - "22.2.6.1.2 Calibration and Offset Error Correction Sequences P. 857" but I dont know how and where I can find for examle CAL_EN (ADCALCR.0). Please help! Sorry for my bad English.

best regards

V.W

  • Hello Vitaliy,

    HalCoGen generates ADC calibration sample code. In HL_adc.c, there are 2 functions: adcCalibration() and adcMidPointCalibration(). You can use either of them.

    adcCalibration() computes the offset error using calibration mode.

    adcMidPointCalibration(): computes the offset error using the mid point calibration mode.

  • Thank you for your fast reply!

    I tried to store the value of the adcCalibration() with the following code:

    #include "HL_adc.h"


    int main(void)
    {
    adcData_t adc_calibration_data;
    adcData_t *adc_calibration_data_ptr = &adc_calibration_data;
    uint32 ADC_value_offset;

    adcInit();

    while(1)
    {

    adcCalibration(adcREG1);
    adcStartConversion(adcREG1, 1U);
    while(!adcIsConversionComplete(adcREG1, 1U));
    adcGetData(adcREG1, 1U, adc_calibration_data_ptr);

    ADC_value_offset = adc_calibration_data_ptr->value;

    }

    return 0;
    }


    The ADC_value_offset was 4294967144. If I subtract the ADC_value_offset from  2^32 = 4294967296, the result is 152. Is this the right procedure to calculate the offset?

  • Hello Vitaliy,

    The adcCalibration() computes the offset and writes this value into ADCALR register in the 2's complement form. You don't need to compute the offset again in your code.

    During normal operation (when calibration is disabled), the ADCALR register contents are automatically added to each digital output from the AD core before it is stored in the ADC results memory. The value you read back from ADC memory is the corrected value.

    I assume you use 12-bit mode, the value you read from the DAC memory should be less than or equal to 0xFFF.

  • Hello Wang, 

    I use now the adcMidPointCalibration(adcREG2);. I noticed that when I connect a pulldown resistor to PIN 7  - AD2IN, the ADC  mesure a value of 0,543 V (lower image). How is this possible where AD2IN is an Input Channel? There should not be any current flow while connected to the GND and there is no input (lower image) , when floating it would makes sense.

    ADCALR Register has now a value of 0x00000004 when I use the adcCalibration(adcREG2);. While I am using the adcMidPointCalibration(adcREG2);, ADCALR has a value of 0x00000FF9. I build againd a voltage divider ( upper image) to proof the values of the adc. The incoming ADC voltage is now around 2,42V. I have  difference of around 56 mV. Where comes this from?

    Best regards

    Vitaliy

  • Hi Vitaliy,

    some question that might help to solve your problem:

    - Did you check the voltage level on ADC output pin when it is floating?

    - Have you already tried another adc input pin in case that the input stage is damaged?

    Regards

    René

  • Hello René,

    I haven't found the output pin, or do yo mean the input pins with output pins?

    I checked all input pins of ADC1 and ADC2 with multimeter. I have mesured 0,035V - 0,049V between ADCIN and GND.

    Of cource I have tried another ADC input but the result was the same.

    best regards

    Vitaliy

  • Hey Vitaliy,

    have you already checked the charge time of the sampling capacitor and the source impedance?

    It seems to me as if your voltage divider's impedance is to high - consider the usage of an signal amplifier.

    Regards,

    René

  • Hello Vitality,

    I did several tests on RM57 and LC4357 launchpads, and the value I sampled using ADC1 is correct.

    1. This is my sampled data

       Channel 0: I shorted AD1IN0 to GND directly (J3, pin 3 to pin2)

       Channel 1: floating

       Channel 6: Temp sensor

    2. The offset of adcCalibration() is 0x0B

        The offset of adcMidPointCalibration() is 0x09

        They are very close to each other.

       

  • Hello René and QJ Wang,

    I have noticed, like René have mentioned before, that the current for Csamp was to low due to the high resistors i have used in the voltage divider.

    As I have increased the sample time of the Csamp, the values were just perfect! 

    Newertheless I will use calibration although the errors are not very hight.

    Thank you for advice and assistance!

    Best regards

    Vitaliy