cancel
Showing results for 
Search instead for 
Did you mean: 

Can "HAL_SPI_Receive_DMA" be configured to run continuously without callback?

EZamo.1
Associate II

I'd like to setup a SPI/DMA to read data from a magnetometer such that the new data is saved to memory without any CPU intervention. I understand a timer could be used, but I don't want any gap between when one spi read and the next. The CPU could then read the latest value from memory any time.

1 ACCEPTED SOLUTION

Accepted Solutions

Use circular DMA.

I'm not sure whether Cube had any native method to avoid callbacks, I don't Cube, but generally it's just disabling the DMA interrupts.

JW

View solution in original post

4 REPLIES 4

Use circular DMA.

I'm not sure whether Cube had any native method to avoid callbacks, I don't Cube, but generally it's just disabling the DMA interrupts.

JW

Thanks, ciruclar mode has a sub-option of "double buffer"... do you know if this is because regular circular mode may lead to a race condition where the DMA is updating the memory at the same time the CPU is reading from it? If not, when is double buffer mode needed?

No, in both cases the processor had to cope with the same data rate. Double-buffer mode has a relatively rare true usage on the the fact that it allows to change the memory-side address of the currently inactive buffer.

JW

EZamo.1
Associate II

Sounds like if one needs to ping-pong between transmitting different data then the double buffer mode would be the way go.. but I think circular mode will work fine for my application. Thanks!