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

Post here first, or if you can't find a relevant section!
Post Reply
meier13
Posts: 13
Joined: Wed Feb 01, 2023 3:09 pm

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

Post 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
Ulrich

It's 106 miles from Chicago, we have a full tank of gas, half a pack of cigarettes, it's dark, and we're wearing sunglasses.

(Blues Brothers)
dannyf
Posts: 447
Joined: Sat Jul 04, 2020 7:46 pm

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

Post by dannyf »

never used the chip myself but presummably there is a register / bits that control the internal reference?
meier13
Posts: 13
Joined: Wed Feb 01, 2023 3:09 pm

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

Post 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.
Ulrich

It's 106 miles from Chicago, we have a full tank of gas, half a pack of cigarettes, it's dark, and we're wearing sunglasses.

(Blues Brothers)
meier13
Posts: 13
Joined: Wed Feb 01, 2023 3:09 pm

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

Post 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+
Ulrich

It's 106 miles from Chicago, we have a full tank of gas, half a pack of cigarettes, it's dark, and we're wearing sunglasses.

(Blues Brothers)
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

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

Post 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:
meier13
Posts: 13
Joined: Wed Feb 01, 2023 3:09 pm

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

Post by meier13 »

Thank you fpiSTM, that was what i am asking for but i did not found by myself.
Ulrich

It's 106 miles from Chicago, we have a full tank of gas, half a pack of cigarettes, it's dark, and we're wearing sunglasses.

(Blues Brothers)
uvulaillfated
Posts: 1
Joined: Thu Feb 16, 2023 3:21 am

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

Post by uvulaillfated »

I can use the system API ll run it useful. Thanks for the advice.
Post Reply

Return to “General discussion”