I have a custom PCB with an STM32F303K8T6 microcontroller onboard. Three values need to be measured with the ADC, but the values from the ADC do not match with the voltages measured at the ADC pins.
The voltages for the ADC2 are both 1.64 V and the measured values are 364 and 2001. ADC1 seems to have an offset (around 0-600) that changes over the applied voltage, like it is temperature dependent. I had such a problem on a STM32F4 Discovery, where the diode was the problem, but here I don't use any diode that could cause that problem.
The reference voltage at the VDDA/VREF+ is exactly 3.3 V (measured). The schematic and the setup in the CubeMX is attached in the images at the bottom. The code to achieve the ADC measurements is the following:
HAL_ADC_Start(&hadc1); while(HAL_ADC_PollForConversion(&hadc1, 0) != HAL_OK) ; measurement1 = HAL_ADC_GetValue(&hadc1); HAL_ADC_Stop(&hadc1); HAL_ADC_Start(&hadc2); // Start regular conversion of regular group (channel 4 and 5) while(HAL_ADC_PollForConversion(&hadc2, 0) != HAL_OK) ; measurement2 = HAL_ADC_GetValue(&hadc2); measurement3 = HAL_ADC_GetValue(&hadc2); HAL_ADC_Stop(&hadc2);