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.
10 years, 6 months ago.
AnalogIn() reading speed (Sampling rate) of STM32F401RE shows weird results
Hi, I have the following code to test the speed of analogin.read( ) on STM32F401RE. Right after flashing the code, the time for analog read is 5us. However, if I press reset button on the board (the black one), then the time it takes is 44us. Does anyone know why?
ADC analogin speed test
#include "mbed.h"
Timer t;
float x;
AnalogIn ain(A0);
int main(void)
{
t.start();
x = ain.read();
t.stop();
printf("time for analog read: %d\r\n", t.read_us());
printf("read data: %f\r\n", x);
}
logs of the above program (first run and subsequent runs after pressing of reset button
Logs: time for analog read: 5 read data: 0.303297 time for analog read: 44 read data: 0.224420 time for analog read: 44 read data: 0.217338 time for analog read: 44 read data: 0.179976
Question relating to:
1 Answer
9 years, 10 months ago.
How about if you try loop ? like .. t.start(); for(int i=0; i<100; i++) { x = ain.read(); } t.stop();
The result may be 44uS + 99*5us, if so, it shows more start-up time is required after reset by button.