I'm quite new to STM32 and Cube HAL. Hardware is custom, mcu is STM32F042G6Ux, created initial code with Cube MX. IDE is SW4STM32.
The issue is that the ADC value is alternating somewhat between two values (roughly 300-something mostly and sometimes 1700-something). I see it while debugging, I do one iteration of the main while-loop and watch the ADC value adc_val returned from HAL_ADC_GetValue function. The voltage is around 450mV. The reading of the internal temperature via ADC is stable and fine.
Here is the code (how to embed code properly?): http://pastebin.com/rvLLcXsk