Skip to main content
Graduate
June 24, 2024
Question

SPI DMA Receive Index on external Interrupt

  • June 24, 2024
  • 2 replies
  • 865 views

Hello, 

I have configured  SPI Slave Receive only with Circular DMA, and I can receive data fine. 

My problem is that I want to have the current receive index on the SPI DMA Buffer when I receive an external interrupt 

I try to use StreamIndex but it show always the same value...

How do I get the current positioning of the received buffer 

 

Thanks 

Vincent 

 

 

 

    This topic has been closed for replies.

    2 replies

    vbessonAuthor
    Graduate
    June 24, 2024

    I tried to use  &hspi3.hdmarx->Instance->NDTR

    but it is not giving me right result. 

    before the start of the receive transfer I cleaned the  buffer with 0

    I only send FF

    I know that I received 152 bytes (last bytes before next 0).

    How do I get the received buffer index, position, size when I stop the DMA 

    Vincent 

     

    Super User
    June 24, 2024

    > I tried to use &hspi3.hdmarx->Instance->NDTR; but it is not giving me right result.

    And what result does it give?

    That's the proper method, just realize, that NDTR counts from its initial value downwards.

    (There is a caveat, if you attempt to read the newest item in the buffer too soon after reading NDTR, it may not be there yet. )

    JW

    vbessonAuthor
    Graduate
    June 24, 2024

    Hello Jan, 

    ok for the downwards for receive, it is the same for the NDTR on send ?

    Thanks 

    Vincent