STM32 value optimized out when reading from ADC
You need to make 'value' volatile or perform some dummy operation on it after loading to prevent your compiler from optimizing out. Bonus tip, if you're in System Workbench, you might want to change your compiler settings to 'optimize for debug' if you're using a debugger tool. You also may want to consider using the DMA peripheral, which pairs nicely with STM32's ADC.