Example code to configure internal Vrefbuf on STM32G474RE (Nucleo -G474RE)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-11-01 9:24 AM
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
Solved! Go to Solution.
- Labels:
-
STM32G4 Series
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-11-01 11:27 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-11-01 11:27 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-11-01 11:38 AM
Hi Peter,
Thanks a lot.
David
