2024-12-10 08:33 AM
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,
Solved! Go to Solution.
2024-12-10 10:33 AM
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.
2024-12-10 09:07 AM
Look at DMA, e.g. timer triggers DMA and DMA reads ADC
2024-12-10 09:22 AM
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,
2024-12-10 09:31 AM
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 ;)
2024-12-10 09:44 AM
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,
2024-12-10 09:52 AM - edited 2024-12-10 09:55 AM
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.
2024-12-10 09:57 AM
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 !
2024-12-10 10:14 AM
Why do you need half duplex when working with the ADC? What ADC? Half Duplex will not work in the scheme above.
2024-12-10 10:19 AM
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,
2024-12-10 10:33 AM
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.