cancel
Showing results for 
Search instead for 
Did you mean: 

Example code to configure internal Vrefbuf on STM32G474RE (Nucleo -G474RE)

DNYAR.1
Associate II

Is there an example code to configure the internal VREFBUF on the STMG474RE (Nuclo-G474RE board).

 to output for example 2.5V to be used by the ADCs. I do not want to use the external reference on the board.

Thanks

David

1 ACCEPTED SOLUTION

Accepted Solutions
Peter BENSCH
ST Employee

Example code is generated by STM32CubeMX, if you set the VREFBUF Mode in the peripheral module SYS to Internal voltage reference and then set the Internal Voltage reference scale in Parameter Settings to SCALE 1: around 2.5V. The STM32G474 will then be generated correctly in stm32g4xx_hal_msp.c, function HAL_MspInit():

__HAL_RCC_SYSCFG_CLK_ENABLE(); // necessary so that SYSCFG can be configured and switched on
[...]

/* System interrupt init */
/** Configure the internal voltage reference buffer voltage scale */
// for SYSCFG_VREFBUF_VOLTAGE_SCALE1 see RM0440, section 23.4.1, bits VRS
HAL_SYSCFG_VREFBUF_VoltageScalingConfig(SYSCFG_VREFBUF_VOLTAGE_SCALE1);

/** Enable the Internal Voltage Reference buffer */
HAL_SYSCFG_EnableVREFBUF();

/** Configure the internal voltage reference buffer high impedance mode */
HAL_SYSCFG_VREFBUF_HighImpedanceConfig(SYSCFG_VREFBUF_HIGH_IMPEDANCE_DISABLE);

Hope that helps?

Regards
/Peter

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

View solution in original post

2 REPLIES 2
Peter BENSCH
ST Employee

Example code is generated by STM32CubeMX, if you set the VREFBUF Mode in the peripheral module SYS to Internal voltage reference and then set the Internal Voltage reference scale in Parameter Settings to SCALE 1: around 2.5V. The STM32G474 will then be generated correctly in stm32g4xx_hal_msp.c, function HAL_MspInit():

__HAL_RCC_SYSCFG_CLK_ENABLE(); // necessary so that SYSCFG can be configured and switched on
[...]

/* System interrupt init */
/** Configure the internal voltage reference buffer voltage scale */
// for SYSCFG_VREFBUF_VOLTAGE_SCALE1 see RM0440, section 23.4.1, bits VRS
HAL_SYSCFG_VREFBUF_VoltageScalingConfig(SYSCFG_VREFBUF_VOLTAGE_SCALE1);

/** Enable the Internal Voltage Reference buffer */
HAL_SYSCFG_EnableVREFBUF();

/** Configure the internal voltage reference buffer high impedance mode */
HAL_SYSCFG_VREFBUF_HighImpedanceConfig(SYSCFG_VREFBUF_HIGH_IMPEDANCE_DISABLE);

Hope that helps?

Regards
/Peter

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Hi Peter,

Thanks a lot. 

David