How to enable 12bit for STM32F103

Tags: #<Tag:0x00007f6e0edb3f98> #<Tag:0x00007f6e0edb3ca0>

I’m trying to use STM32F103C8 with EmonLib. STM32 has 12bits ADC. It would be good to use it.
I tried to enable it by using setup parameter


However, it does not fly. I got an error

'analogReadResolution' was not declared in this scope

Seems that this command works only for Arduino Due.

I tried to change default resolution in the library Emonlib.h.

// to enable 12-bit ADC resolution on Arduino Due,
// include the following line in main sketch inside setup() function:
//  analogReadResolution(ADC_BITS);
// otherwise will default to 10 bits, as in regular Arduino-based boards.
#if defined(__arm__)
#define ADC_BITS    1̶2̶    10
#define ADC_BITS    1̶0̶    12

Is it enough?


See STM32duino+emonlib - strange behavior