2025-03-18 8:52 AM
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
2025-03-18 9:09 AM
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.
2025-03-18 10:17 AM
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.
2025-03-18 10:55 AM
Start from examples:
script:
pins GPIO:
Pay attention how array is defined:
/* Buffer used for reception */
#define BUFFER_ALIGNED_SIZE (((BUFFERSIZE+31)/32)*32)
ALIGN_32BYTES(uint8_t aRxBuffer[BUFFER_ALIGNED_SIZE]);
Alignment is important when working with dma.
2025-03-18 11:10 AM
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.
2025-03-18 11:36 AM
Thanks for all these links, I’ll have a look.
2025-03-18 11:39 AM
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.
2025-03-18 3:36 PM
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?
2025-03-19 2:16 AM
For both ADC1283 and ADC120 from STM, the datasheet doesn't specify the fastest stream measurements over SPI, but since the Dout pin is supposed to be straight binary, I just assume that I can operate the SPI at the max sampling frequency (respectively 200ksps and 1Msps). Also in the ADC1283 datasheet, on page 1 I can see that the device was tested at 200ksps with a clock of 3.2 MHz (so SCLK). For these reasons I would say the max SPI clock rate is the max sampling frequency multiplied by the data length (so 16 bits for these 2 ADCs). Correct me if i'm wrong. For the TI references, i.e. ADS1118, ADC128s102 and ADC121s051, the SPI protocol seems to be more detailed on the datasheet, so might be easier.
2025-03-19 8:33 AM
"For these reasons I would say the max SPI clock rate is the max sampling frequency multiplied by the data length (so 16 bits for these 2 ADCs)."
I'd say 16 clock cycles, not bits, since both 12-bits adc.
Yes, quite slow 3.2 MHz, even arduino UNO could handle this rate.
8 Channels simply 'd means 200 ksps /8 = 25 ksps / channel sampl. rate.
Should be easy, my latest struggle was with ADS8354 Dual, High-Speed, 16-Bit, Simultaneous-Sampling, where I have to clock-out data for both channels in the same time frame.