2023-10-25 04:56 PM
I'm using an STM32U575 chip with a couple of it's peripherals. I'm trying to get the ADC1 working. It's currently sampling a few pins, but when I read the data, it seems to always be 4095 (max value). Looking into it further, the VREF+ pin is sitting at 0V, which correlates with the max value reading I'm seeing.
I was initially planning on using the internal reference for this board, but I'm having trouble turning it on. The HAL provides the function `HAL_SYSCFG_EnableVREFBUF()`, but when I step through this execution, it never turns on the ENVR bit.
What am I missing here?
2023-10-25 05:24 PM - edited 2023-10-25 05:24 PM
What chip exactly do you have (letters after STM32U575)? Is VREF+ separated from VDDA? Is VDDA powered?
It isn't clear if you have to enable the SYSCFG clock first, but you can try it:
__HAL_RCC_SYSCFG_CLK_ENABLE();
2023-10-25 09:49 PM - edited 2023-10-25 09:54 PM
The specific chip is STM32U575ZIT6Q. I do have separate VREF+ and VDDA pins on the package. VDDA is tied to the same power rail as VDD, which is set at 1.8V. I've verified VDDA is powered by probing it with a meter, and it's at 1.8V. I have VREF+ isolated with only some bypass caps to ground, as recommended in the hardware design guide (AN5373). I have put in a footprint for an external voltage reference if need be, but I'd prefer to use the internal one if possible.
I'll try that function when I get back to the office tomorrow.
2023-10-26 08:10 AM
Should be doable then. If you're stuck, you may want to create a project in CubeMX and see what code it generates. Probably you are missing something.
1.8V is the lower limit of what VREFBUF requires to function and likely only the 1.5V reference is usable at that voltage.
2023-10-26 10:29 AM
I've been using CubeMX within the CubeIDE to generate the code. I was using it before with the Nucleo board, and I didn't need to do anything extra to get it working on there.
So I'm at a loss as to what's different. I'll go back and do another check on the Nucleo schematic and whatnot to see if there's anything I missed.
2023-10-26 01:37 PM
I didn't solve the original problem of using the internal reference, but I did find that the Nucleo board does have VDDA and VREFP shorted together using a jumper. Shorting those on my board started giving me expected values from the ADC, which is good.
However, it would be nice to use the internal reference if possible. Otherwise, it would be good to figure out if the docs should be updated.
2023-10-26 08:10 PM
The whole flow for enable the VREF to use the VREFBUF is as below:
__HAL_RCC_SYSCFG_CLK_ENABLE();
HAL_SYSCFG_VREFBUF_HighImpedanceConfig(SYSCFG_VREFBUF_HIGH_IMPEDANCE_DISABLE);
HAL_SYSCFG_VREFBUF_VoltageScalingConfig(SYSCFG_VREFBUF_VOLTAGE_SCALE1);
HAL_SYSCFG_EnableVREFBUF();