2026-03-24 2:25 PM - last edited on 2026-03-24 2:50 PM by mƎALLEm
I am using a G474RE nucleo board and i have 2 separate interface boards which i ca connect to it.
One board requires a VREFBUS of 2.5V and the other 2.90 .
Currently i modify the .IOC file and select the appropriate VREFBUS, compile the code. So currently i have 2 separate .elf files, one for each scenario.
I will want a single code version so that on start up based on the status of a switch connected to a GPIO,
it will configure the correct VREFBUF value.
The attachment shows my setup for the 2.90V internal voltage reference.
Thanks
David
Solved! Go to Solution.
2026-03-24 3:45 PM - edited 2026-03-24 3:47 PM
@DNYAR.1 wrote:
I do not see where the appropriate cubeMX code is created. It is not in my main.c file (like the other peripheral initializations).
Is there another file i need to look into for that?
Thanks
A thread related to the same subject you've already created in 2023 Example code to configure internal Vrefbuf on STM32G474RE (Nucleo -G474RE) ;)
2026-03-24 2:31 PM
Hello,
That's not possible to set two configurations for two different voltage reference in CubeMx.
You need to do that in the user code i.e. configure the VREFBUF in the user code section based on the GPIO state.
2026-03-24 2:52 PM
Sorry i did not come across clearly. What i want is user code to set that up using a GPIO pin to select between the
2 possible internal buffer voltages.
2026-03-24 2:57 PM - edited 2026-03-24 3:32 PM
In the user code:
if (GPIO_pin_status == SET)
{
configure VREF_Buff to 2.5
}
else
{
configure VREF_Buff to 2.9
}
Generate the code with cubeMx for both configurations and paste the VREFBUF config related code in the respective condition.
And here is a thread related to the same subject you've already created in 2023 Example code to configure internal Vrefbuf on STM32G474RE (Nucleo -G474RE)
2026-03-24 3:43 PM
I do not see where the appropriate cubeMX code is created. It is not in my main.c file (like the other peripheral initializations).
Is there another file i need to look into for that?
Thanks
2026-03-24 3:45 PM - edited 2026-03-24 3:47 PM
@DNYAR.1 wrote:
I do not see where the appropriate cubeMX code is created. It is not in my main.c file (like the other peripheral initializations).
Is there another file i need to look into for that?
Thanks
A thread related to the same subject you've already created in 2023 Example code to configure internal Vrefbuf on STM32G474RE (Nucleo -G474RE) ;)