cancel
Showing results for 
Search instead for 
Did you mean: 

SPI Read without CPU Intervention

unkn0wn
Associate II

Hello Everyone,

I have a STM32H755 MCU connected to an external ADC via SPI in half duplex. I'd like to read ADC value at 2KHz. Ideally I'd like to avoid to interrupt the CPU 2K times per second to read ADC values, as a consequence I'm looking for a way to trigger SPI reading without CPU intervention. Is it possible ?

Please note, my MCU is master on the SPI.

 

Regards,

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Uwe Bonnes
Principal III

It might be possible, but I think it is not worth the effort. As  I do not see an explicit "half duplex" mode in the ADS8866 datasheet, you should first verify your scheme with CPU interaction. The load should be minimal.

View solution in original post

9 REPLIES 9
Uwe Bonnes
Principal III

Look at DMA, e.g. timer triggers DMA and DMA reads ADC

Hey Uwe,

 

Thank you for the answer ! I have read the documentation you've mentionned. Unfortunately, I still don't figure out if it is possible to trigger a SPI read without CPU intervention.

Indeed, I am wondering how it is possible to trigger a read on the SPI perpiheral from a DMA transfert, especially on half duplex master. (is it really possible or should I forget it ?)

 

Regards,

Timer at 2 Khz triggers DMA. Dma writes to SPI RX and shifts out e.g. 16 bits  for a 16 bit ADC word when set right. SPI TX complete triggers another DMA channel to read SPI RX to memory. Second channel DMA buffer half/full  interrupt tiggers semaphore to allows main program can manipulate data.
Nearly straight forward ;)

I might be a noob, but they are something that I don't understand here aha.

What I understood : 

    * I should use TRGO to internally map a timer overflow to a DMA controller
    * I should link a DMA controller with my SPI block.

What I dont understand (after reading your answers) : 

    * How exactly can I trigger a SPI read (so sending the clock on the SCLK) through a DMA.

I might have not understand your answer correctly, but I still don't get what will trigger my SPI Read sequence.

 

Regards,

For the H7, e.g. DMA_REQUEST_TIM1_UP  could start the readout by writing a word into SPI1_TX, DMA_REQUEST_SPI1_TX  would then read out SPI1_RX.

However a 2 kHz interrupt load is no big load to the H7, so perhaps first try w/o DMA if your CPU is not to busy.

Oh okay I think I got it.

Does it make sens to write on SPI1_TX if I want to read at the same time on a single line (half duplex)

Thanks a lot Uwe !

 

Uwe Bonnes
Principal III

Why do you need half duplex when working with the ADC? What ADC? Half Duplex will not work in the scheme above.

I am working with the ads8866

Due to hardware constraints I won't have two data lines for doing full duplex but rather one for half duplex.

Does it kill any possibility then ?

 

Regards,

Uwe Bonnes
Principal III

It might be possible, but I think it is not worth the effort. As  I do not see an explicit "half duplex" mode in the ADS8866 datasheet, you should first verify your scheme with CPU interaction. The load should be minimal.