0
\$\begingroup\$

I 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 analog signal between 500KHz to 900Khz.

 #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?

asked May 6, 2019 at 9:49
\$\endgroup\$
1
  • 3
    \$\begingroup\$ Bias the ADC input, using a voltage divider with 2 resistors, each 10Kohm. Monitor the midpoint with a scope, AC coupled and 0.1 volt/division. You will see the ADC sampling events, as a quick drop in voltage and a slower recharge. What is the frequency of those events? is the timing consistent? \$\endgroup\$ Commented May 6, 2019 at 9:56

1 Answer 1

1
\$\begingroup\$

You are hitting limits when Arduino IDE starts being "unfriendly" and it is in my opinion easier to use more "professional" IDE. Your current code has problem that you make 1 ADC conversion (with X default parameters) and then you send them through serial link to PC. This is slow, especially if you are using a lot of HAL drivers and standard functions with a lot of overhead.

For your project, if you want to achieve reliable ADC sample frequency you will need to use set up ADC yourself and transfer data to SPI via DMA. You can setup all of this in Arduino IDE but I think it can be done much more easily in other IDEs. You can find list of recommended IDEs on STM page about your board.

answered May 6, 2019 at 12:54
\$\endgroup\$

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.