cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H723 DMA works well, but after i copy the data which dma wrote, dma doesnt work anymore.

Dongdongguri
Associate II

Hi, thanks for reading my question.

I use DMA for ADC, and it works well, one shot mode, and starts gain, data changed well from the ADC.

But, if I read the data, then DMA works but it cant write it into the memory.

 

 

#define MAX_DMA_MEMORY_SIZE	2552

ALIGN_32BYTES (static uint8_t ADC_DMAMemory[MAX_DMA_MEMORY_SIZE]);

HAL_ADC_Start_DMA(&hadc1, (uint32_t *) ADC_DMAMemory, MAX_DMA_MEMORY_SIZE);

 

 

 and just copy the data 1 time

 

 

    	for(int i = 0; i < nsize; i++)
    	{
    		pVal[i] =  ADC_DMAMemory[i+ioffset];
    	}

 

 

I use dma for 2552 data, and copy 2048 data to pVal. So just copied 389th array to 2437th.

and after this copy, DMA refresh only 0 to 384th, and 2438 to 2552. 

DMA never write data to the address where i copied.

if i dont copy data, it works well, every time, it writes new data.

 

Please help me, i just went through H7 weird data cache usage, and i met another problem.

Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
FBL
ST Employee

Hello @Dongdongguri 

First try to disable the cache and see if the issue disappears. If so, you should maintain data cache coherency. 

 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

View solution in original post

4 REPLIES 4
FBL
ST Employee

Hello @Dongdongguri 

First try to disable the cache and see if the issue disappears. If so, you should maintain data cache coherency. 

 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

thanks, i thought i tested it, but i didnt.

below is working now.

void HAL_ADC_ConvHalfCpltCallback(ADC_HandleTypeDef *hadc)
{
	SCB_InvalidateDCache_by_Addr((uint32_t*) &ADC_DMAMemory[0], 2552/2);
	memcpy(&ppiVal[0], &ADC_DMAMemory[0], MAX_DMA_MEMORY_SIZE/2);
}

 

Piranha
Chief II

That is not enough. The size of every half-buffer must be a multiple of the cache line size. And the buffers must be invalidated before and after the DMA reception.

https://community.st.com/t5/stm32-mcus-products/maintaining-cpu-data-cache-coherence-for-dma-buffers/m-p/95746

So i have 2 choice, invalidate it before and after the DMA, or just using Link script to make 0x30000000 to use DMA memory, i tested 0x30000000 to 0x30000200, it works. and I will use LAN too. maybe i can use next address for this. then all problem will be solved.

Thank you.