Cortex-M4 内存争用(DMA 对程序)

Cortex-M4 Memory contention (DMA against program)

我正在使用 STM32F4xx 控制器。 我使用 DMA 来缓冲 UART(循环缓冲区)。 我担心的是当我的程序与DMA同时访问相同的内存位置时是否会出现内存争用。

争用是否会以这种方式发生,或者控制器有措施防止这种情况发生?

谢谢。

我在STM32F401手册中找到了这个:

The BusMatrix manages the access arbitration between masters (CPU, DMA). The arbitration uses a round-robin algorithm.

DMA(或CPU)可能由于仲裁而不能(在正确的时间)进行传输。这会导致 underrun/overrun 错误(在 DMA 中,CPU 将等待)。

If the DMEIFx or the FEIFx flag is set due to an overrun or underrun condition, the faulty stream is not automatically disabled and it is up to the software to disable or not the stream by resetting the EN bit in the DMA_SxCR register. This is because there is no data loss when this kind of errors occur.