cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F030R8T6 ADC Calibration Error

sanju
Senior

i am using Nucleo-F030R8 board. I want to get adc calibration factor.

By writing

#define VREFINT_CAL (*((uint16_t *) 0x1FFFF7BA))

i got VREFINT_CAL = 1521 which is actually factory stored value, that good no problem.

but when i try to calibrate it by self writng

MX_ADC_Init();

while(HAL_ADCEx_Calibration_Start(&hadc) != HAL_OK);

VREFINT_CAL = HAL_ADC_GetValue(&hadc);

i got VREFINT_CAL = 64 or 65. what is this i am not getting it.

it should around 1521.

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

That is correct.

The calibration value is stored internally during the calibration process and used during future ADC conversions. You can read it out if you want, but it doesn't change the operation of the ADC and you don't use it when converting raw readings to voltages.

The reference manual describes this.

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

6 REPLIES 6
Uwe Bonnes
Principal II

Is your VREF the same as with factory calibration?

Yes

When I select ch17 in channel selection register and start adc to convert, the converted value that I get is 1526 which is around 1521.

But when I start calibration there ​is 64 or 65 is result

Even it cannot be greater than 127 because DR6:0(7bits) give the calibration value.

What wrong am I understanding here.​

TDK
Guru

Calibrating the ADC returns the calibration value, not the value for VREFINT.

If you want to measure VREFINT, first calibrate the ADC, then measure the VREFINT channel.

If you feel a post has answered your question, please click "Accept as Solution".

Ok so let me know you what I am doing in code

1. First I am calibrating the adc which is giving value of 64 or 65 something.

2. Then I am reading the value of vrefint​ by selecting this channel which is giving 1525 value

So as per ​my understanding

What datasheet says that typical value of vrefint should be 1.23 v

So this result 1525 ​is representing 1.23v ideally

Means if I go mathematically

4095 will represent (1.23/1526)​*4095 = 3.3028v

If I am wrong here pls correct me.

And If I am right then what is use of this calibration factor 64 or 65 whatever it gives​.

TDK
Guru

That is correct.

The calibration value is stored internally during the calibration process and used during future ADC conversions. You can read it out if you want, but it doesn't change the operation of the ADC and you don't use it when converting raw readings to voltages.

The reference manual describes this.

If you feel a post has answered your question, please click "Accept as Solution".

Thank you for the reply.

My understanding was right about vrefint channel value.

But I was in doubt with this calibration factor value 64 or 65 that why this is provided to the user.

But as you are saying user don't have to use it for any kind of calculation​.

Thing which matters to the user is vrefint channel value.