I want to use DMA memcpy from one external SDRAM region to another.
I know, I have to invalidate cache or disable caching with MPU, in order to have transparent transfers with the DMA. I chose to use the MPU like this:
Code: Select all
#define SDRAM_DEVICE_ADDR 0xC0000000UL
/*
* Configure memory protection region with disabled cache in SDRAM
* This ensures that DMA access is not hidden behind unchanged caches
*
* Assumes 32 MiB SDRAM.
*/
mpuConfigureRegion(
MPU_REGION_6,
SDRAM_DEVICE_ADDR,
MPU_RASR_ATTR_AP_RW_RW |
MPU_RASR_ATTR_NON_CACHEABLE |
MPU_RASR_SIZE_32M |
MPU_RASR_ENABLE);
However, this is not effective. In the following code, "MEM" is a memory region on SDRAM, starting at "0xC0000000UL". The data that I can examine in MEM[20] is only correct, if I use the manual buffer invalidation before!
Code: Select all
MEM[0] = 18;
// cacheBufferInvalidate(MEM, 8); <= With this line, it works!
dmaStartMemCopy(INT_MEM_DMA_STREAM,
STM32_DMA_CR_PL(0) | STM32_DMA_CR_PSIZE_BYTE |
STM32_DMA_CR_MSIZE_BYTE,
&MEM[0], &MEM[20], 8);
Is there some configuration error in the MPU?
Thanks in advance,
Adrian