Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
9 years, 9 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:
1 Answer
9 years, 8 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?
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