STM32H7 - Using ADC with DMA is corrupting memory.
I'm having trouble using ADC with DMA. It is working correct, I'm getting the correct result. But DMA is corrupting another data which is not related with DMA in runtime. I'm also using Ethernet, because of it, I can not disable D-Cache.
I do my Ethernet, DMA, MPU configurations according to the following article (without RTOS)
And also I read
https://community.st.com/s/article/FAQ-DMA-is-not-working-on-STM32H7-devices
But like I say, I do not want to disable d-cache.
I use example in STM32Cube repository to use ADC with DMA:
void HAL_ADC_ConvHalfCpltCallback(ADC_HandleTypeDef* hadc)
{
if(hadc == &hadc1)
{
/* Invalidate Data Cache to get the updated content of the SRAM on the first half of the ADC converted data buffer: 32 bytes */
SCB_InvalidateDCache_by_Addr((uint32_t *) &adc1.m_rawResult[0], 7);
}
if(hadc == &hadc3)
{
/* Invalidate Data Cache to get the updated content of the SRAM on the first half of the ADC converted data buffer: 32 bytes */
SCB_InvalidateDCache_by_Addr((uint32_t *) &adc2.m_rawResult[0], 8);
}
}
void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc)
{
if(hadc == &hadc1)
{
/* Invalidate Data Cache to get the updated content of the SRAM on the first half of the ADC converted data buffer: 32 bytes */
SCB_InvalidateDCache_by_Addr((uint32_t *) &adc1.m_rawResult[4], 7);
}
if(hadc == &hadc3)
{
/* Invalidate Data Cache to get the updated content of the SRAM on the first half of the ADC converted data buffer: 32 bytes */
SCB_InvalidateDCache_by_Addr((uint32_t *) &adc2.m_rawResult[4], 8);
}
}Thank you!
