cancel
Showing results for
Did you mean:

# How to measure power supply internally on STM32F107?

Associate III

Hello community,

I'm working on a STM32F107VCT6 where I have practically (by means of very basic filtering) shorted on the PCB VDD/VDDA/VREF+/VBAT and VSS/VSSA/VREF-.

I've runned out of pins so I was wondering if there were a way to measure the power supply (without using external ADC channels) which supplies the MCU (VDD) for the purpose of evaluating the upstream power supply conversion (done by a DCDC).

An interesting application here on the forum based on STM32L010F4 using VREFINT_CAL solution could have been perfect if only STM32F107 had this register (which actually don't).

As a desperate attempt I was doing Vsupply=3.3V*Vrefint/Vmeas. Where Vrefint=1.20V from datasheet, Vmeas is Vrefint measured by means of ADC1 "Vrefint Channel". But it seems stupid to me because falls in a circular reference thus the Vsupply will always be calculated as 3.30V... Or maybe not?

Any smarter solutions?

1 ACCEPTED SOLUTION

Accepted Solutions
Guru

Sure.

Call VADC the voltage at the ADC pin. We know that's 1.2V because the datasheet says so.

The ADC counts are given by COUNTS = 4096 * VADC / VREF+.

Rearrange that to solve for VREF+:

VREF+ = VADC * 4096 / COUNTS

So if your counts are 1638: VREF+ = 1.2 * 4096 / 1638 = 3.00

If your counts are 1489: VREF+ = 1.2 * 4096 / 1489 = 3.30

5 REPLIES 5
Guru

Measure VREFINT, assume it's 1.20 V per the datasheet, and extrapolating the reading to determine what VREF+/VDDA/VDD is.

You don't need VREFINT_CAL to be able to do this.

Associate III

Hi @TDK​ , thanks for you answer (again). This idea led me to the "disperate attempt" above, but my consideration is: if Vrefint is always 1.20V no matter what voltage if I supply to the MCU (in his operating voltage range of course, 2.0 to 3.6 V), how can the two voltages be correlated?

In less word: can you define your "extrapolation" above?

Guru

Sure.

Call VADC the voltage at the ADC pin. We know that's 1.2V because the datasheet says so.

The ADC counts are given by COUNTS = 4096 * VADC / VREF+.

Rearrange that to solve for VREF+:

VREF+ = VADC * 4096 / COUNTS

So if your counts are 1638: VREF+ = 1.2 * 4096 / 1638 = 3.00

If your counts are 1489: VREF+ = 1.2 * 4096 / 1489 = 3.30

Guru

Let's denote the voltage on VREF+ as vrefext , maximum ADC readout which corresponds to this voltage as MAX=4096, voltage on the bandgap as vrefint=1.2V and the ADC readout of this voltage as REFINT. The ADC is proportional thus

vrefint/vrefext = REFINT/MAX

from which

vrefext = MAX/REFINT * vrefint

or

JW

Associate III

Ha, that's quite funny...I was implementing that formula modifying the one I got in my first post then I realized:

Vsupply=3.3V*Vrefint/Vmeas <<<mine
=3.3V * 1.2V /Vmeas=
=3.3V * 1.2V / (ADCVAL* 3.3V/4096)=
= 1.2V * 4096 / ADCVAL <<<suggested

So basically I already had already implemented the suggested formula... 🙂 I just didn't realize why it could have been working. I ignored the idea that the 3.3V in my formula was not the reference value but the max ADCval ...

I used the days where the forum got into maintenance to make some tests at different Vin that I can confirm performed well...

Thanks both!