Spark Logic

STM32F091 ADC resolution 10 bit instead of 12 bit

GianniDPC Sat Jun 24, 2017 4:04 pm

I just tested the ADC on my Nucleo STM32F091 board, and it shows a 10-bit resolution like the original Arduino’s but my board supports 12-bit. If I look in to the source code, I see that the resolution is also defined as 12-bit.

Do I need to set something differently to achieve a 12-bit resolution?
Source code: https://github.com/stm32duino/Arduino_ … /variant.h

void setup() {
Serial.begin(9600);
}

void loop() {
long sensorValue = analogRead(0);
Serial.println(sensorValue);
}

Replies

Rick Kimball Tue Jun 27, 2017 5:39 pm

[fpiSTM – Tue Jun 27, 2017 12:20 pm] –
wow there’s lot of smoke here :)

To sum up, stm32 is 3.3V based so provide 5V as input ADC should bring some strange behavior… Mainly for ADC reading.

FYI, on the next release analogRead(0) and analogRead(A0) will be equivalent.
whereas analogWrite(0) is equivalent to analogWrite(D0) .

I tried the latest github source code version with this change and I can verify that it indeed works with just 1 now in addtion to A1.

RogerClark Tue Jun 27, 2017 9:32 pm

[zmemw16 – Tue Jun 27, 2017 3:26 pm] –
roger,
could you please try it with 7.5v / 9v / 12v and report your findings :D
actually 12v would be redundant as i already know the answer is copious.
stephen

I may try 5v again, because I have 2 old Red Pill boards, which are partially broken already, as the USB connections keep breaking

Sign in to reply