Skip to main content
Visitor II
March 18, 2025
Question

Reading continuous data from an external ADC with SPI at a high sample rate

  • March 18, 2025
  • 3 replies
  • 1584 views

Hello everyone,

I'm new to STM32CubeIDE and working on a project that requires high-speed SPI communication between an external ADC and an STM32H7A3 microcontroller (i'm using a Nucleo board). My goal is to sample data up to 1MSPS (not sure if its completely realistic), but currently I'm only achieving about 500 samples per second (1 sample every 2ms).

I've attempted to implement DMA and internal timers to increase the conversion rate without success. Once I get the SPI working at an appropriate speed, I need to transmit this data via UART (limited to 115200 baud) to a Python GUI for post-processing. Since the UART speed is lower than my target SPI sampling rate, I plan to buffer the samples until reaching capacity before transmission.

The ultimate purpose of this project is to evaluate how certain ADC datasheet parameters drift when the device is exposed to specific external conditions.

Since the ADC communication seems to be a well known topic, I was wondering if anyone successfully implemented a similar communication setup who could offer guidance or share example code?

Thank you,
Simon

 

    This topic has been closed for replies.

    3 replies

    Explorer
    March 18, 2025

    I have a few projects using nucleo-H743zi2, adc 16-18 bits at max 1.5 msps.

    Can't tell for H7A3, but main problem with H7 series is that:

    -DMA-1-2 not always have access to memory, check documentation for specific uCPU;

    -memory is not continuous, verify .ld script;

    -good things SPI has special feature to trigger CS line, so using timers not required.

    SimonThrAuthor
    Visitor II
    March 18, 2025

    Hi, thanks for your reply. After looking at the documentation, I think DMA have indeed access to memory. I'm planning to use a RAM to store the sampled data before transferring it to the terminal, does it have to be initialised in the main.c file? I'm a bit confused with all the files automatically created by the IDE. Also could you share 1 of your projects to see how you configured the pins etc to see how you managed to reach 1 MSPs or more? I think i'm still missing some crucial considerations in order to get these communications working properly. 

     

    Explorer
    March 18, 2025
    SimonThrAuthor
    Visitor II
    March 18, 2025

    Thanks for all these links, I’ll have a look.

    Super User
    March 18, 2025

    Can you reconsider and use the internal ADC of the STM32H7A? It is quite capable and has DMA.

    The UARTs, by the way, have DMA too.

     

    SimonThrAuthor
    Visitor II
    March 18, 2025

    Hi, thanks for your reply. My final goal is to develop a setup to qualify 5 ADCs already selected against disturbances caused by the environment, so I won’t be able to use the integrated ADC of the nucleo board. 

    Super User
    March 18, 2025

    Then it depends on your SPI-connected ADC chip. Can it take and stream measurements over SPI faster than 1µs/sample? What is its maximum SPI clock rate?