Page 1 of 1

Nucleo STM32H7: Setting VRefBuf

Posted: Wed Apr 27, 2022 4:23 pm
by erognal
Dear stm32duino community,

maybe you can help me out with this question.

1) How to set internal VREF with stm32duino? analogReference() is not implemented.

Thank you very much,
erognal

Re: Nucleo STM32H7: Setting VRefBuf

Posted: Fri May 20, 2022 9:20 am
by fpiSTM
Hi, right it is not implemented. Maybe you could use LL or HAL driver to set it directly.

Re: Nucleo STM32H7: Setting VRefBuf

Posted: Fri May 20, 2022 9:50 am
by ag123
in stm32 VREFINT is a fixed voltage measured off a constant voltage source.
if that is what you want to read, you may be able to read that using analogRead().
https://github.com/stm32duino/wiki/wiki ... l-channels

stm32 ADCs don't have a feature that set a vref as like a comparator. Check the datasheets for your chip
and the range would normally be from 0-vdd (3v3) based on how the chip is wired or wired internally.

Re: Nucleo STM32H7: Setting VRefBuf

Posted: Fri May 20, 2022 10:26 pm
by GonzoG
erognal wrote: Wed Apr 27, 2022 4:23 pm Dear stm32duino community,

maybe you can help me out with this question.

1) How to set internal VREF with stm32duino? analogReference() is not implemented.

Thank you very much,
erognal
I think that STM32 MCUs don't have internal ADC reference, they use external (or on MCUs without Vref pins, it's connected to power supply pins).
VREFBUF can be used only for DAC.

Re: Nucleo STM32H7: Setting VRefBuf

Posted: Sat May 21, 2022 12:12 am
by MasterT
Something like:

Code: Select all

  
    __HAL_RCC_VREF_CLK_ENABLE();
    HAL_SYSCFG_VREFBUF_HighImpedanceConfig(SYSCFG_VREFBUF_HIGH_IMPEDANCE_DISABLE);
    HAL_SYSCFG_EnableVREFBUF();
More options in stm32h7xx_hal.h

Code: Select all

#define SYSCFG_VREFBUF_HIGH_IMPEDANCE_DISABLE  ((uint32_t)0x00000000) /*!< VREF_plus pin is internally connected to Voltage reference buffer output */
#define SYSCFG_VREFBUF_HIGH_IMPEDANCE_ENABLE   VREFBUF_CSR_HIZ        /*!< VREF_plus pin is high impedance */

#define IS_SYSCFG_VREFBUF_HIGH_IMPEDANCE(__VALUE__)  (((__VALUE__) == SYSCFG_VREFBUF_HIGH_IMPEDANCE_DISABLE) || \
                                                      ((__VALUE__) == SYSCFG_VREFBUF_HIGH_IMPEDANCE_ENABLE))

#define IS_SYSCFG_VREFBUF_TRIMMING(__VALUE__)  (((__VALUE__) > 0UL) && ((__VALUE__) <= VREFBUF_CCR_TRIM))