cancel
Showing results for 
Search instead for 
Did you mean: 

How to set a VRef for most precise ADC reading STM32F411EC?

MLemo.1
Associate III

Hello,

I'm working on my own E load test equipment for my lab that will double as a battery capacity tester and I decided to use out lovely favorite chip the stm32F411ECU AKA "Black pill"

So I've set up the conversion amount to around 20 @ continues mode and migrating from the arduino world I know that in order to eliminate the background noise of the 3.3V regulator that the stm32 usually take reference from you can setup an Internal voltage reference that usually comes built in the chip.

So the question it does the STM32F411EC have an internal VRef? how many? how stable? how do you set it up?

8 REPLIES 8
MLemo.1
Associate III

Fount this using LL abstraction but how do you use it?:

__STATIC_INLINE void LL_ADC_SetCommonPathInternalCh	(	ADC_Common_TypeDef * 	ADCxy_COMMON,
uint32_t 	PathInternal 
)		
Set parameter common to several ADC: measurement path to internal channels (VrefInt, temperature sensor, ...).
 
One or several values can be selected. Example: (LL_ADC_PATH_INTERNAL_VREFINT | LL_ADC_PATH_INTERNAL_TEMPSENSOR)
 
Note:
On this STM32 family, setting of this feature is conditioned to ADC state: All ADC instances of the ADC common group must be disabled. This check can be done with function LL_ADC_IsEnabled() for each ADC instance or by using helper macro helper macro __LL_ADC_IS_ENABLED_ALL_COMMON_INSTANCE(). CCR VREFEN LL_ADC_SetCommonPathInternalCh
CCR TSEN LL_ADC_SetCommonPathInternalCh
CCR VBATEN LL_ADC_SetCommonPathInternalCh
Parameters:
ADCxy_COMMON	ADC common instance (can be set directly from CMSIS definition or by using helper macro __LL_ADC_COMMON_INSTANCE() )
PathInternal	This parameter can be a combination of the following values:
LL_ADC_PATH_INTERNAL_NONE
LL_ADC_PATH_INTERNAL_VREFINT
LL_ADC_PATH_INTERNAL_TEMPSENSOR
LL_ADC_PATH_INTERNAL_VBAT
Return values:
None	

Rather than reading arbitrary functions descriptions, read the appropriate chapters of reference manual.

The internal reference is probably not usable as a direct reference to the ADC, unless this STM32 has a way to connect it to the VREF+ pin (through VREFBUF module - I didn't check but I doubt any 'F4 has this).

On smaller packages VREF+ is internally connected to VDDA, so you don't have much options to improve on that, except serious filtering (note that VDDA must not depart much from VDD). Also, ADCs on heavily digital circuits are disappointingly noisy, principally, so better don't hold your breath and be prepared to move to an external ADC if you won't be able to achieve performance you require.

JW

TDK
Guru

Don't confuse VREFINT for a voltage reference usable by the ADC. It's a ~1.21V internal signal readable by one ADC channel. Details in the datasheet.

If VDDA/VREF+ has a high ripple current, nothing is going to be able to reduce the noise from that, apart from averaging many samples.

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

So there is no actual way to improve the accuracy of the ADC reading except over sampling or get an external ADC?

TDK
Guru

Read AN2834 to see your options:

https://www.st.com/resource/en/application_note/cd00211314-how-to-get-the-best-adc-accuracy-in-stm32-microcontrollers-stmicroelectronics.pdf

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

This is nice and all but nothing about how to setup an external voltage reference in software...

The voltage applied to the VREF+ pin is your voltage reference. There's nothing to configure...
If you feel a post has answered your question, please click "Accept as Solution".

huh, OK thank you then I think you can't set it much with the stm32f411CE black pill module.