Failing to read useful data from ADC of STM32f411
Hello,
upfront, it might be an incredibly dumb problem on my behalf as I am fairly new to this.
For a couple days now I have been trying to read out the voltage through the onboard ADC configured for 12 bits but all I am getting back are values in a similar range (mostly somewhere in between 1500 and 1800 but that changes with the amount of delay that I introduce, does that help?). The value itself does change, floating within that range.
I have tested for faulty connections and switched the board but the issue persists.
It is a very basic setup, just a potentiometer connected to the A0, and it works if I use an Arduino with its framework to try and read the value (the potentiometer is not broken). But also supplying A0 with ground or 3.3v directly doesn't change the read value. After reading the value I write it to serial, which is also working.
My guess is that something with my clock configuration is wrong and the ADC has not enough time to run a meaningful measurement.
I hope that any of you can help, thank in advance!
the main loop (is there any better way to format code blocks?):
while (1)
{
HAL_ADC_Start(&hadc1);
HAL_Delay(500);
HAL_ADC_PollForConversion(&hadc1, 100);
value_adc = HAL_ADC_GetValue(&hadc1);
HAL_ADC_Stop(&hadc1);
// value_adc, message and len are defined outside of the main function
sprintf(message, "value: %hu\r", value_adc);
while(CDC_Transmit_FS(message, len) != USBD_OK);
memset(message, '\0', len);
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
I used CubeMx to generate the pretty much all other code, besides a tiny bit in the CDC_Receive_FS function for communication. Here is my ADC configuration:

PCLK2 is configured for 14Mhz
