After CPU has updated the data buffer, but the DMA still transfers the old content in the buffer instead of the updated one.
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
After CPU has updated the data buffer, but the DMA still transfers the old content in the buffer instead of the updated one.
TMS570LC43x and RM57Lx have DMA and Data Cache (DCACHE). We can use DMA for data transfer between peripheral and memory, or between memory and memory. The DMA transfer does not go through MCU DCACHE. It writes data directly to memory. The SRAM is protected by MPU. The cache policy and allocation are programmable.
Write-back with write allocate (WBWA) provides the best performance. The cache hits only update the cache memory. Cache misses on a write, copy data from the main memory to the cache. As a result, subsequent access results in a cache hit. Read-allocate is permanently enabled by default.
The cache is enabled on SRAM and the cacheability attribute is set to write-back with write-allocate (WBWA). The CPU has previously read the DMA buffer and therefore, the same data is available in the cache memory due to the read allocate policy.
1. Cache Coherency Issue - DMA Writes to SRAM
2. Cache coherency Issue - DMA Reads from SRAM
There are two mechanisms to maintain coherency:
1. Disable caching
This is the simplest mechanism but might cost significant MCU performance. To get the highest performance, the CPU is pipelined to run fast, and to run from caches which offer a very low latency. Caching of data that is accessed multiple times increases performance significantly and reduces SRAM accesses. Marking data as "non-cached" could impact performance.
2. Software managed coherency
Software managed coherency is the traditional solution to the data sharing problem. The software must clean or flush dirty data from caches, and invalidate old data to enable sharing with other bus master (CPU or DMA).
1. When DMA writes to SRAM condition:
coreInvalidateDCByAddress(uint32 u32Address, uint32 u32Size);
2. When DMA reads from SRAM Conditions:
coreCleanDCByAddress(uint32 u32Address, uint32 u32Size);