user16805: I just got myself a STM32F103C8 Blue pill board. I am having funny behaviour with the analog readings. It behaves as if the unit was 10bits and not 12 bits.
I uploaded the very trivial Arduino code below. Just to read the analog input A0.
void setup() {
  Serial.begin(38400);
}
void loop() {
  Serial.println(analogRead(A0));
  delay(1000);
}

If I connect pin A0 to the 3.3v I get this output below.
1022
1022
1023
1022
1022
etc...

If I connect to a 1.5V source the above values becomes around 500.
It all behaves as if it was 10bits really which I fail to understand. Any ideas why?

user16805: Adding the following line in the setup() section solves the problem.
analogReadResolution(12)


user-1: If you run Arduino code on it, maybe it makes sense to have 10-bit ADC readings on this platform too like on all other Arduino platforms. Unless you configure the libraries to return full 12 bit, if even possible.
This is more an Arduino platform question though.

16805: <p>I just got myself a STM32F103C8 Blue pill board. I am having funny behaviour with the analog readings. It behaves as if the unit was 10bits and not 12 bits.</p>
<p>I uploaded the very trivial Arduino code below. Just to read the analog input A0.</p>
<pre><code>void setup() {
  Serial.begin(38400);
}
void loop() {
  Serial.println(analogRead(A0));
  delay(1000);
}
</code></pre>
<p>If I connect pin A0 to the 3.3v I get this output below.</p>
<pre><code>1022
1022
1023
1022
1022
etc...
</code></pre>
<p>If I connect to a 1.5V source the above values becomes around 500.</p>
<p>It all behaves as if it was 10bits really which I fail to understand. Any ideas why?</p>
 16805: <p>Adding the following line in the setup() section solves the problem.</p>
<pre><code>analogReadResolution(12)
</code></pre>
 -1: <p>If you run Arduino code on it, maybe it makes sense to have 10-bit ADC readings on this platform too like on all other Arduino platforms. Unless you configure the libraries to return full 12 bit, if even possible.</p>
<p>This is more an Arduino platform question though.</p>
