cancel
Showing results for 
Search instead for 
Did you mean: 

0.5 MSPS external ADC

Stabilo
Associate III

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 !

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

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".

View solution in original post

8 REPLIES 8
TDK
Guru

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
Associate III

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
Guru

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
Associate III

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 ?

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
Associate III

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 ...

In slave mode, the SPI does not generate a clock.
If you feel a post has answered your question, please click "Accept as Solution".
Stabilo
Associate III

Ok I did not understand that the SPI had to be configured as a slave.

I will definitely try that.

Thanks a lot.