2023-05-17 03:33 PM - edited 2023-11-20 05:11 AM
Hi All,
I created an STM32CubeIDE project to set up an Internal voltage reference on my
board that has an STM32G473VCT; see the screenshot attached. All I did was
create that Internal voltage reference, save and generate code. See screenshot:
I put breakpoints at the end of HAL_StatusTypeDef HAL_SYSCFG_EnableVREFBUF(void)
in /Sample_STM32G473VCT3_project_03/Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal.c
at return HAL_TIMEOUT; and return HAL_OK;. Debugging and running it, it stopped
on "return HAL_TIMEOUT".
Looking at the datasheet, which I downloaded from mouser,
("Newest member cannot add links", so I had to remove the links.)
Pg 15: Table 2. STM32G473xB/xC/xE features and peripheral counts (continued)
says that STM32G473 Cx,Rx,Mx,Vx,Qx all have the Internal voltage reference buffer.
Pg 32, section 3.20 says:
The STM32G473xB/xC/xE devices embed a voltage reference buffer which can be used
as voltage reference for ADC, DACs and also as voltage reference for external
components through the VREF+ pin.
The VREF+ pin is double-bonded with VDDA on some packages. In these packages the
internal voltage reference buffer is not available.
Table 12. STM32G473xB/xC/xE, has the pin definitions. Pg 59/229 shows pin 36 and
pin 37 separate for VREF+ and VDDA respectively. If they were bonded, it would
show them both on one ball/pin. So there should be an Internal voltage reference
on this micro. It is LQFP100 -Table 12 seems to misspell this as LPQF100.
I did take a look at "How to configure VREFBUF on my STM32" in the Knowledge
Base, and I do have a scale set. Is there anything else I could have missed?
Does anyone know what could be causing this failure?
Thanks in advance for your assistance.
Best regards,
2023-05-18 12:35 PM
Most probably you did not enable VREFBUF clock in RCC (somewhat surprisingly, it's enabled by RCC_APB2ENR.SYSCFGEN, see description of this bit in RM).
Also note, that if using VREFBUF, the VREF+ pin has to be connected to capacitance of specific value (typ. 1uF + a small ceramic like 100nF for HF suppression), and not connected to any significant load or any other circuitry.
JW
2023-05-18 01:21 PM
Thanks for your reply.
All I did was create that Internal voltage reference, save and generate code.
One would think that STM32CubeIDE would add all of the correct code. Indeed the
generated code has void HAL_MspInit(void) which does
__HAL_RCC_SYSCFG_CLK_ENABLE() which contains
SET_BIT(RCC->APB2ENR, RCC_APB2ENR_SYSCFGEN). I verified that execution is doing
that.
According to my schematic, the micro does have 1 uF and 0.1 uF connected to
VREF+.
What else could be wrong? Maybe problems with the board that an electronics/
hardware expert should investigate.
2023-05-23 01:16 PM
It was found that pins 36 and 37 were soldered together on the board I was using.
Unsoldering those allowed VRefBuf to come up.
There was a mistake in the auto-generated STM32CubeIDE code: the
SYSCFG_VREFBUF_HIGH_IMPEDANCE_DISABLE had to be put *before*
"HAL_SYSCFG_EnableVREFBUF();" in HAL_MspInit(); in stm32g4xx_hal_msp.c; the
autogenerated code had it after. When I moved it before, execution was stopping
on "return HAL_OK;" in HAL_SYSCFG_EnableVREFBUF() in stm32g4xx_hal.c instead of
"return HAL_TIMEOUT;".
I have ver 1.12.1 of the STM32CubeIDE, Build: 16088_20230420_1057 (UTC). I could
post more version and build numbers of subcomponents if that would help.
2023-05-24 04:00 AM
Thanks for coming back with the solution.
JW
@Amel NASRI , hi, can the Cube/CubeMX crew please check the issue with HAL_SYSCFG_EnableVREFBUF() and HiZ being set?