cancel
Showing results for 
Search instead for 
Did you mean: 

My vdd readout is high. Using Vrefint ADC channel.

Henrik Sandaker Palm
Associate II
Posted on January 04, 2017 at 19:51

Hi,

My vdd calculates to 3.49V but I measure it to 3.30V with a voltmeter.

The Vrefint calibration value at 0x1FFFF7BA is 1550.

The ADC value I read is 1465, fluctuating +/- 1.

Calculation is 3.3V * VrefintCalValue / AdcValue = 3.49V

I'm guessing it's my adc read value that is off, not the factory calibration value?

MCU is STM32F042G6Ux. ADC code is done in CubeMX.

ADC is clocked with a prescaler of /4 and sampletime is 239.5 cycles. So all signals should have plenty of time to settle between samples.

Code is inside this link ->

http://pastebin.com/G7bSzfyf

18 REPLIES 18
Posted on March 19, 2017 at 12:29

Usually a bandgap is a structure of transistor which factor out the first order dependency from supply voltage and temperature. Usually around 1.23v it depends on the transistor intrinsic properties (not an expert, this is my rough understanding). The vdd measurement is very handy to convert your analog measurement into milivolt... You need to know if vdda is 3v or 3.3v or 3.6v otherwise no need 12 bit adc...

Posted on March 19, 2017 at 12:42

Thanks for your reply.

If I am running the processor at 2.5v, I assume the below calculation would stay the same as the calibration value (VREFINT_CAL) was set when the VDD was 3.3v?

If my VDD was powered by 2.5v, the below would tell me the exact voltage of the VDD on the processor?

V DDA = 3.3 V x VREFINT_CAL / VREFINT_DATA

Scott

Posted on March 29, 2017 at 16:40

Hi

 As a newbie I am just getting used to the system, and liked the 'Link To Code' above where it shows your code. Would it be possible to add the code you have for the a/d calibration? I am too getting 3.49v, but think I need the calibration.

Many Thanks

Scott

Posted on March 30, 2017 at 11:31

I'm trying to use the ''Synatx highlighter'' function of the forum instead. If you're using HAL, simply do as I do; add the lineHAL_ADCEx_Calibration_Start(&hadc); after ADC initialization, before you start the ADC. See line number 21 below.

int main(void)
{
 /* USER CODE BEGIN 1 */
 /* USER CODE END 1 */
 /* MCU Configuration----------------------------------------------------------*/
 /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
 HAL_Init();
 /* Configure the system clock */
 SystemClock_Config();
 /* Initialize all configured peripherals */
 MX_GPIO_Init();
 MX_DMA_Init();
 MX_ADC_Init();
 MX_USB_DEVICE_Init();
 /* USER CODE BEGIN 2 */
 HAL_ADCEx_Calibration_Start(&hadc);
 HAL_ADC_Start_IT(&hadc);
 /* USER CODE END 2 */
 /* Infinite loop */
 /* USER CODE BEGIN WHILE */
 HAL_Delay(1000);
 while (1)
 {�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?

Edit:

To whoever is reviewing my post: Why is this happening to me, all of a sudden? That my posts needs reviewing.

0690X00000606elQAA.png
Posted on March 30, 2017 at 13:09

The person who reviewed my post obviously didn't read it, since I don't see a reply to my question.

Posted on March 30, 2017 at 14:14

That isn't the purpose of a moderation review, which is to check for spam, or offensive or illegal content.

Most links and formatted code now get reviewed due to recent spam levels.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
ryan nguyen
Associate
Posted on May 30, 2017 at 03:05

I ran into the same problem, where the results of my voltage calculation for Vdda as well as other ADCs using the VREFINT are off by 5-6 mV. I solved my issue by decreasing the adc sampling rate which was 1.5 adc clock cycle to 55.5 adc clock cycle, and now it's only off by ~ 1mV. I think the reason being the adc might need more time to charge up its cap depending on the resistance of the adc line. Hope this help.

Taras Chornenkyi
Associate
Posted on November 13, 2017 at 12:32

Hi!

VREFINT_CAL is the result of conversion of 3.0 V by the ADC. So you should use 3.0 instead of 3.3 in you calculations.

I have the following formula in the reference manual for stm32l476:

VDDA = 3.0 V x VREFINT_CAL / VREFINT_DATA 

http://www.st.com/content/ccc/resource/technical/document/reference_manual/02/35/09/0c/4f/f7/40/03/DM00083560.pdf/files/DM00083560.pdf/jcr:content/translations/en.DM00083560.pdf

 
Posted on May 23, 2018 at 14:22

I read the whole post and your one sentence gave me the solution.  This was the answer that I was looking for. Thank you very much sir.