cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F103RB VREFINT_CAL value?

Josue Guillen
Associate II
Posted on February 07, 2018 at 00:21

Hello, I�m trying to get a precise measure with the ADC of the NUCLEO-F103RB but I can�t get a stable result. I measure the internal reference voltage in IN17 of ADC1 but the value is also unstable, so I think there is where my problem is. I want to know the value of VREFINT_CAL to make the adjustment in the measure,but I could not find it in the reference manual or anywhere in the documentation.

#stm-32 #nucleo-stm #adc-supply #voltage-reference
6 REPLIES 6
T J
Lead
Posted on February 07, 2018 at 08:59

Turn down the ADC clock source add a prescaler as much as you can.

Did you use the Cube ?  much easier to visualize on the Cube

after the ADCs are calibrated the values are much better. (within a mV or two)

check the reference manuals, try some examples

try to get both the Temperature and Vref and Calibration running.

my '091 is currently reading 43.8 with 27.9 ambient. about 16C above ambient.

Posted on February 07, 2018 at 17:49

Thanks for your reply T J. I´m using the Cube, the main clock is running at 56MHz and the ADC clock at 7MHz and each channel have a sampling time of 55.5 cycles.

I calibrate the ADC after the initialization with the function HAL_ADCEx_Calibration_Start(&hadc1), but I the values I get are the same.

I have noticed that vdd change from 3.25V to 3.89V when I connect my circuit, so the vref change too. I want to know where I can read the VREF_CAL value to compare the difference with the vref in IN17 so I can adjust the other measures.

henry.dick
Senior II
Posted on February 07, 2018 at 23:54

Not really sure what you meant the adc isn't stable. Unless you have an adc designed by God, it will not deliver the same reading when fed the same voltage. It goes up and down randomly. It is not uncommon for 8 bit adcs to fluctuate 2 to 4 lsb. More for higher resolution adcs.

So maybe you are trying to solve a problem that doesn't exist.

Posted on February 07, 2018 at 23:45

I initialise like this:

            HAL_ADC_Stop_DMA(&hadc);    // stop is instant

            ADC_DMA_Wait = true;               // waiting to recalibrate the ADC due to variant PCB temperature affecting ADC accuracy

            ADChasBeenRecalibrated = false;

after a few milliseconds, I wait 100...  the DMA and all conversions stop.

then,

    if((ADC1->CR & ADC_CR_ADEN) != 0)                  // (1)

    {

        ADC1->CR &= (uint32_t)(~ADC_CR_ADEN);  // (2)

    }

    ADC1->CR |= ADC_CR_ADCAL;                              // (3)

    while((ADC1->CR & ADC_CR_ADCAL) != 0) // (4)

    {

        checkBackgroundServices();

        // For robust implementation, add here time-out management

    }

    ADC_CalibrationFactor = (ADC1->DR);     //& 0x7F);

    ADChasBeenRecalibrated = true;

    char string[32];   

    sprintf(string, 'ADC Recal is Completed\n\r');    

    puts1(string);

                    

    HAL_ADC_Start_DMA(&hadc, (uint32_t *)ADC_DMABuffer, ADC_ChannelCount);   // adc-start

Posted on February 08, 2018 at 00:09

Thanks dhenry I´m using a 12 bit ADC and fluctuates like 8 lsb so Ithink you are right and I´m trying to solve a problem that doesn´t exist

Posted on February 08, 2018 at 00:12

With that said, an amazing feature on some of adc modules is the availability of two calibration values. It makes first order correction of adc results so much easier. 

Not sure if that what you are trying to do initially. But that's not available on all chips.