2025-03-16 6:54 AM
Hello!
A simple question.
If I run DAC, using HAL_ADCEx_MultiModeStart_DMA(..., buffer, ...), when D-cache is disabled, I succeed to send what I filled in the buffer.
If I do the same with enabled D-cache, I don't succeed.
SCB_InvalidateDCache_by_Addr() function, which is useful in ADC callbacks, seems to be not helpful for DAC.
How to fix that?
2025-03-16 7:16 AM
Before starting the DAC DMA transfer, call:
SCB_CleanDCache_by_Addr((uint32_t*)buffer, buffer_size);
where:
2025-03-16 11:46 AM - edited 2025-03-16 12:04 PM
The command to FLUSH the pending memory for a DMA (memory-to-peripheral) is SCB_CleanDCache_by_Addr()
The SCB_InvalidateDCache_by_Addr() throws away the pending/dirty cache content, ie stuff you've created in the buffer. It's what you'd use when DMA (peripheral-to-memory) has changed the underlying content of the memory
Remember that the by_Addr() expects 32-byte alignment buffers and sizes. You need to add guard zones around the buffers if you can't do that, the Invalidate can do collateral damage.