Skip to main content
EZamo.1
Associate III
February 13, 2020
Solved

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

  • February 13, 2020
  • 3 replies
  • 922 views

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.

This topic has been closed for replies.
Best answer by waclawek.jan

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

3 replies

waclawek.jan
waclawek.janBest answer
Super User
February 13, 2020

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

EZamo.1
EZamo.1Author
Associate III
February 14, 2020

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?

waclawek.jan
Super User
February 14, 2020

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
EZamo.1Author
Associate III
February 16, 2020

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!