STM32H7 ADCs with DMA when D-Cache enabled
Dear all,
I am trying to configure ADC1, ADC2 (ADC1 and ADC2 in multimode) and ADC3 running simultaneously with DMA.
I have a running code for STM32F7 series and I assumed that I could use DMA in the same manner but DMA cannot store data taken from ADC1,2 and 3. DMA transfer complete interrupts occur for ADC1 and ADC3 and ADC12_Common and ADC3 Data registers change and there is no overrun error. So, ADCs work fine and DMA looks like working fine. However, the register where DMA supposed to write didn’t change. Therefore, I searched in the community and I found some articles. I realized that when D-cache is enabled, DMA cannot store data to the buffer even it is located to an address which is above 0x24000000. I thought that if DMA stores data to SRAM1, it may solve the problem because SRAM1 and DMA are on the same domain and luckily it worked with one problem.
Pieces of my code is as follows:
HAL_DMA_Start(&hdma_adc1,(uint32_t)&ADC12_COMMON->CDR ,(uint32_t)0x30000000, 6); // Start DMA.
0x83F1 is the first ADC result at 0x30000000 and 0x30000001.
0x8354 is the second ADC result at 0x30000002 and 0x30000003 so on.
So, DMA works well when D-cache is enabled. Then I would like to define a variable at 0x30000000 as follows:
volatile uint32_t ADC12_Result[6] __attribute__((section(".ARM.__at_0x30000000")));
HAL_DMA_Start(&hdma_adc1,(uint32_t)&ADC12_COMMON->CDR ,(uint32_t)&ADC12_Result,6); // Start DMA.
I supposed that it will work because ADC12_Result is located to 0x30000000. However, it didn't work. After that, I disabled D-cache and it worked well.
What is the difference between two different settings? Is there any very clear working examples that I can easily implement. There are some explanations in https://community.st.com/s/article/FAQ-DMA-is-not-working-on-STM32H7-devices
However, I am not expert about MPU and I didn't understand well. Cache maintenance functions may help me but I didn't understand how to implement for ADC.
ADC resolution is 16 bits and ADC_Common->DR contains ADC2 and ADC1 result after every conversation. There will be 6 conversations and we need 32 bits array with a size of 6.
Thank you very much for your contribution and help.
