2023-10-11 02:09 AM
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.
Solved! Go to Solution.
2023-10-11 02:57 AM
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.
2023-10-11 02:57 AM
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.
2023-10-11 06:35 PM
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);
}
2023-10-12 04:37 PM
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.
2023-10-25 01:20 AM
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.