cancel
Showing results for 
Search instead for 
Did you mean: 

[BUG] ADC2_ConversionConfig()

Michal Dudka
Senior III

Function ADC2_ConversionConfig do three steps:

  1. sets ADC result align
  2. enable/disable continuous conversion (there will be problem, unrelated to Continuous mode)
  3. writes desired channel into ADC2->CSR (there will be another problem)

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

0 REPLIES 0