2020-06-30 01:33 AM
Function ADC2_ConversionConfig do three steps:
but if that function is called with enabled ADC (ADON=1), it suprisingly start conversion because of clearing CONT bit in ADC2->CR1 (any write into ADC2->CR1 with ADON bit set starts conversion). Because of this behaviour, function cannot be used to change channel while ADC is ON.
Also in step 3. is problematic. Changing channel selection is done in two steps (clear bits CH[3..0] and next write desired value). This means that for short period of time is AIN0 selected as ADC input and if that GPIO serves for exaple as output, it typicaly leads to realy bad situations ... (output becomes input absolutelny unexpectedly).
Tested at STM8S208 (Nucleo) with Standard Peripherals Library V2.3.1 / 26-April-2018