Skip to main content
JStro.2
Visitor II
April 19, 2020
Question

STM Nucleo 32F303K8 slow analog on Arduino IDE

  • April 19, 2020
  • 1 reply
  • 995 views

Both the Arduino Due and STM Nucleo 32F303K8 resolution is set as 12bits.

Digital speed is the instruction set a pin high and then low.

In my code I avoided using loops so I coded the instruction 1000 times to get a more accurate reading of the instruction itself.

The STM Nucleo 32F303K8 has a specified analog input of upto 5MSPS but it takes 187 micro seconds to get only one sample. Why on the Arduino IDE is the STM Nucleo 32F303K8 analog so slow? The Arduino Due manages 4.116 microsecond per sample, but on the digital test the STM Nucleo 32F303K8 is about 2.5 times faster.

float time1;

float time2;

void setup() {

 // put your setup code here, to run once:

 Serial.begin(9600);

 analogReadResolution(12);

}

void loop() {

 // put your main code here, to run repeatedly:

 time1 = micros();

 analogRead(A0); //1

 analogRead(A0); //2

 analogRead(A0); //3

…………………

 analogRead(A0); //999

 analogRead(A0); //1000

 time2 = micros();

 Serial.println(time2-time1);

}

This topic has been closed for replies.

1 reply

Uwe Bonnes
Chief
April 20, 2020

Arduino often codes in an easy way and not in a time-sensitive way. Consider other libraries or rewrite the code in a better way.