STM32: analogReference?

Sorry about total newbie question…so far worked only with Arduino.

I’m trying to read ADC in “disco_l072cz_lrwan1” board (STM32 based) and regular analogReference(INTERNAL) isn’t recognized by compiler.

How do I define I want to use internal reference voltage?

[env:disco_l072cz_lrwan1]
platform = ststm32
board = disco_l072cz_lrwan1
framework = arduino
lib_deps = stm32duino/STM32duino Low Power@^1.2.0

Thanks,
Tipo

Looks like the analogReference() function isn’t used. From wiring_analog.h:

/*
 * \brief Configures the reference voltage used for analog input (i.e. the value used as the top of the input range).
 * This function is kept only for compatibility with existing AVR based API.
 *
 * \param ulMmode Should be set to AR_DEFAULT.
 */
extern void analogReference(eAnalogReference ulMode) ;

And from wiring_analog.c:

void analogReference(eAnalogReference ulMode)
{
  UNUSED(ulMode);
}

It would appear that you must use AR_DEFAULT when calling analogReference().

HTH

Cheers,
Norm.

Thanks Norm,
It compiles with `analogReference(AR_DEFAULT).

But where do I have to go to find out what reference voltage/source is defined by AR_DEFAULT?

Didn’t find any “default” condition for ADC from these docs:

/tipo

Possibly here: analogReference() - Arduino Reference

Also, https://deepbluembedded.com/stm32-adc-tutorial-complete-guide-with-examples/#_STM32_ADC_Resolution_Reference_Formulas, where it seems to indicate that it’s 3.3V unless your development board has VREF tied to a lower voltage than 3.3V.

HTH

Cheers,
Norm.