cancel
Showing results for 
Search instead for 
Did you mean: 

SPI DMA Receive Index on external Interrupt

vbesson
Associate III

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 

 

 

 

3 REPLIES 3
vbesson
Associate III

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 

 

> 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

Hello Jan, 

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

Thanks 

Vincent