8 years, 4 months ago.

Why can't I initialize ADC (AnalogIn) pins A3 through A7.

Can not initialize ADC (AnalogIn) pins A3 through A7 after instantiating AnalogIn A0 through A2 on NUCLEO-F303K8. The output error message is "Cannot initialize ADC".

include the mbed library with this snippet

#include "mbed.h"

Serial pc(USBTX, USBRX);

AnalogIn ain1(A0);
AnalogIn ain2(A1);
AnalogIn ain3(A2);
AnalogIn ain4(A3);
AnalogIn ain5(A4);
AnalogIn ain6(A5);
AnalogIn ain7(A6);

int main() {
    int i;
    while(1) {
        for(i = 0; i < 50; i++) {
            wait(0.5f); // wait a small period of time
            pc.printf("Analog 1:%f \n", ain1.read()); // print the value of variable i
            pc.printf("Analog 2:%f \n", ain2.read()); // print the value of variable i
            pc.printf("Analog 3:%f \n", ain3.read()); // print the value of variable i
            pc.printf("Analog 4:%f \n", ain4.read()); // print the value of variable i
            pc.printf("Analog 5:%f \n", ain5.read()); // print the value of variable i
            pc.printf("Analog 6:%f \n", ain6.read()); // print the value of variable i
            pc.printf("Analog 7:%f \n", ain7.read()); // print the value of variable i
        }
    }
}

Question relating to:

Affordable and flexible platform to ease prototyping using a STM32F303K8T6 microcontroller.

Documentation problem on the platforms page for this board. Look at the mbed lib, analogin_api.c for this part.

posted by Jon Buckman 10 Jan 2016

1 Answer

8 years, 3 months ago.

The ADC is buggy on NUCLEO-F303K8. Got the same error.

Another bug: When values do get out (not mixing A0-A2 and A3-A7) it is 5% too low.

Something wrong with definitions in the mbed SDK for NUCLEO-F303K8?

Accepted Answer

This bug has not yet been solved. the problem depends on the ADC initial calibration. how have you resolved?

posted by Federico Gaetani 26 Dec 2016