Skip to main content
Graduate
December 10, 2024
Solved

SPI Read without CPU Intervention

  • December 10, 2024
  • 3 replies
  • 1423 views

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,

 

 

    This topic has been closed for replies.
    Best answer by Uwe Bonnes

    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.

    3 replies

    Graduate II
    December 10, 2024

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

    unkn0wnAuthor
    Graduate
    December 10, 2024

    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,

    Graduate II
    December 10, 2024

    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 ;)

    Graduate II
    December 10, 2024

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

    unkn0wnAuthor
    Graduate
    December 10, 2024

    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,

    Graduate II
    December 10, 2024

    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.