简体   繁体   English

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

[英]Cortex-M4 Memory contention (DMA against program)

I am using STM32F4xx controller. 我正在使用STM32F4xx控制器。 I have utilized DMA to buffer UARTs (circular buffers). 我已经利用DMA来缓冲UART(循环缓冲区)。 My concern is that if there will be a memory contention when my program accesses the same memory location at the same time as DMA. 我担心的是,当我的程序与DMA同时访问相同的内存位置时是否存在内存争用。

Can contention happen this way, or the controller has measures to prevent this to happen? 争用会以这种方式发生吗,还是控制器有措施防止这种情况发生?

Thanks. 谢谢。

I found this in STM32F401 manual : 我在STM32F401手册中找到了这一点:

The BusMatrix manages the access arbitration between masters (CPU, DMA). BusMatrix管理主机(CPU,DMA)之间的访问仲裁。 The arbitration uses a round-robin algorithm. 仲裁使用循环算法。

It might happen that DMA (or CPU) can not do transfer (at the right time) due to arbitration. 可能由于仲裁而导致DMA(或CPU)无法在正确的时间进行传输。 This causes underrun/overrun error (in DMA, CPU will wait). 这将导致欠载/溢出错误(在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. 如果由于溢出或欠载情况而设置了DMEIFx或FEIFx标志,则故障流不会自动被禁用,并且软件将通过重置DMA_SxCR寄存器中的EN位来禁用或不禁用该流。 This is because there is no data loss when this kind of errors occur. 这是因为发生此类错误时不会丢失数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM