SPI Read without CPU Intervention
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-12-10 8: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.
- Labels:
-
STM32H7 series
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-12-10 9:07 AM
Look at DMA, e.g. timer triggers DMA and DMA reads ADC
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-12-10 9: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,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-12-10 9: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 ;)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-12-10 9: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,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-12-10 9:52 AM - edited ‎2024-12-10 9: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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-12-10 9: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 !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎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,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎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.
