Page 1 of 1

stm32G4xx set to internal Vref of 2.048, 2.5 or 2.9 V

Posted: Mon Feb 06, 2023 3:47 pm
by meier13
Hello,

did anybody set the stm32G4xx to internal Vref of 2.048, 2.5 or 2.9 V or other STM32 with internal reference which can be used?

Thanks in advance

Re: stm32G4xx set to internal Vref of 2.048, 2.5 or 2.9 V

Posted: Wed Feb 08, 2023 12:07 am
by dannyf
never used the chip myself but presummably there is a register / bits that control the internal reference?

Re: stm32G4xx set to internal Vref of 2.048, 2.5 or 2.9 V

Posted: Wed Feb 08, 2023 1:17 pm
by meier13
Yes, there are register(s) to set it, but if anybody made it before and got it running then it would be helpful.

Re: stm32G4xx set to internal Vref of 2.048, 2.5 or 2.9 V

Posted: Thu Feb 09, 2023 3:29 pm
by meier13
ok, it was easier than i thought.

#define VREFBUF (*(volatile uint32_t *)(0x40010030)) // address of the VREF register

To use the internal Reverence:

Bit0 (ENVR) must be set to 1. That swithes to internal reference mode.
Bit1 (HIZ) must be set to 0. That connects the VREF+ pin internally with the vref buffer output. The reference voltage is now also at the VREF+ pin and can be used for other devices. In this mode the VREF+ pin must not connected to another voltage source.
Bit4 and 5 sets the reference voltage. 00= 2.048V, 01= 2.50V and 10= 2.90V.

in my case it is just 1 for 2.048V.
VREFBUF =1;
Now you should check Bit 3 (VRR) until it is set. Then the setup is finished.

https://www.st.com/resource/en/referenc ... ronics.pdf page 770+

Re: stm32G4xx set to internal Vref of 2.048, 2.5 or 2.9 V

Posted: Thu Feb 09, 2023 4:10 pm
by fpiSTM
You can use ll system API by including stm32yyxx_ll_system.h to manage the bits you mentioned:
https://github.com/stm32duino/Arduino_C ... 1158-L1254

with those values for voltage:
https://github.com/stm32duino/Arduino_C ... #L306-L308:

Re: stm32G4xx set to internal Vref of 2.048, 2.5 or 2.9 V

Posted: Thu Feb 09, 2023 5:02 pm
by meier13
Thank you fpiSTM, that was what i am asking for but i did not found by myself.

Re: stm32G4xx set to internal Vref of 2.048, 2.5 or 2.9 V

Posted: Thu Feb 16, 2023 3:23 am
by uvulaillfated
I can use the system API ll run it useful. Thanks for the advice.