Skip to main content
archana95in
Associate II
May 6, 2019
Question

Configuring ADC on Nucleo-F401RE in Arduino IDE gives erratic values for input freq greater than 100Hz

  • May 6, 2019
  • 2 replies
  • 4410 views

0690X000008BIvyQAG.jpgI want to configure ADC on STM32(Nucleo-F401RE) using Arduino IDE and transmit the values through SPI to Basys 3 FPGA(End Goal). The ADC works for input signal frequency only below 100Hz. How do I increase the throughput rate? My project requires conversion of input analog signal between 500KHz to 900Khz.

Attached is the plot for input freq 1KHz,1.2V,Sine wave from Arduino Serial Plotter

#include <f401reMap.h>
 
float analogPin = pinMap(31); //PA0
 
float val = 0; // variable to store the value read
 
void setup() {
 Serial.begin(115200); // setup serial
 analogReadResolution(12);
 
}
 
void loop() {
 val = analogRead(analogPin); // read the input pin
 Serial.println(val); // debug value
}

In the past,I have used Keil and STMCubeMX. It did not sample the input signal below 100Hz which was achievable using Arduino IDE. I have tried increasing the sampling cycles, the issue persists. Configured ADC without DMA with HAL_ADC_Start function and transferred the values to PC through UART,still unable to retrieve the original signal. I'm unable to isolate where the problem lies. What am I missing?

This topic has been closed for replies.

2 replies

waclawek.jan
Super User
May 6, 2019

I'd say

> Serial.println(val); // debug value

takes cca 10ms.

JW

archana95in
Associate II
May 6, 2019

Would configuring a ADC with DMA help ?

Ozone
Principal
May 6, 2019

> Serial.begin(115200); // setup serial

Some rough bandwidth estimates are helpful before starting to implement.

115200 bps gives you about 10 kbytes per second - without overhead.

archana95in
Associate II
May 6, 2019

Okay, thank you! I increased the baud rate to 2000000 and works till 400Hz. But I'm still quite far away from the range I would require.  STM32(Nucleo-F401RE) ADC of 2.4MSPS sampling rate. Can I expect better results if I send the values to FPGA, store them in a memory and transmit then using UART ?

Ozone
Principal
May 6, 2019

Best option would be to drop the real-time UART transmission. Isn't it for debug anyways ?

With two bytes per ADC value and >2 Msps get you roughly 5 MBytes/s, or 50Mbps of required bandwidth.

Perhaps USB or ethernet, but not UART.