Skip to main content
Stabilo
Associate III
October 7, 2021
Solved

0.5 MSPS external ADC

Hello,

I want to use a STM32F7 to retrieve ADC measurements from an external ADC over SPI (16-bit read operation to retrieve the measurement).

In theory, it should be possible.

My question is: how can I retrieve the measurements minimizing the host processor load ?

My idea is to ;

  • use a 48 Mhz SPI
  • use an interrupt to trigger SPI read.
  • use SPI read operation with DMA to store the data in buffer.

The problem is that my interrupt will fire each 2us ... I don't think this is reasonable on a microcontroller.

Is there a smarter way to do that on a MCU ?

Or should I choose another solution like FPGA or DSP ?

Thanks !

This topic has been closed for replies.
TDK
TDKBest answer
October 7, 2021

It's still possible, a little complicated.

Use a master timer to trigger the ADC.

Use a slave timer in gated mode (off of master timer) to generate the 16 SCK clocks.

Use SPI slave in receive mode to get data.

"If you feel a post has answered your question, please click ""Accept as Solution""."

8 replies

TDK
October 7, 2021

Adjust your SPI clock such that it reads 16 bits every 2us and have it continuously read, then use DMA to transfer many values at once. You can use half- and full-complete callbacks to process the data.

"If you feel a post has answered your question, please click ""Accept as Solution""."
Stabilo
StabiloAuthor
Associate III
October 7, 2021

Thank you TDK.

This is a great idea, but my ADC is a bit particular.. I need to trigger the ADC measurement by a GPIO rising edge. I need to see if I can continuously "poll" the SPI bus,

TDK
TDKBest answer
October 7, 2021

It's still possible, a little complicated.

Use a master timer to trigger the ADC.

Use a slave timer in gated mode (off of master timer) to generate the 16 SCK clocks.

Use SPI slave in receive mode to get data.

"If you feel a post has answered your question, please click ""Accept as Solution""."
Stabilo
StabiloAuthor
Associate III
October 7, 2021

Thank you !

If I understand correctly, the slave timer allows to generate a kind of "delayed" interrupt, and is this interrupt I can read data through SPI ?

TDK
October 7, 2021
I wouldn't use interrupts on each sample. That's going to be too many. Set up the SPI to transfer into a large buffer using DMA, possibly a circular buffer, then process it at some later time, perhaps during the half- and full-complete interrupts, which will be generated by the DMA reaching a certain number of transferring values.
The slave timer is just used to generate the SCK clock. Set it up as a 50% PWM, set up the master timer to be high for exactly 16 clock cycles.
"If you feel a post has answered your question, please click ""Accept as Solution""."
Stabilo
StabiloAuthor
Associate III
October 7, 2021

The only point that I don't understand is: the SPI peripheral is already generating a clock signal right ? Maybe there will be a conflict between the SPI generated clock and the one generated by the slave timer ...