DAC in DMA mode @ enabled cache
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎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?
Solved! Go to Solution.
- Labels:
-
DAC
-
DMA
-
STM32H7 Series
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-03-16 7:16 AM
Use SCB_CleanDCache_by_Addr() Before Enabling DMA
Before starting the DAC DMA transfer, call:
SCB_CleanDCache_by_Addr((uint32_t*)buffer, buffer_size);
where:
- buffer is the pointer to your DAC buffer.
- buffer_size is the number of bytes in the buffer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-03-16 7:16 AM
Use SCB_CleanDCache_by_Addr() Before Enabling DMA
Before starting the DAC DMA transfer, call:
SCB_CleanDCache_by_Addr((uint32_t*)buffer, buffer_size);
where:
- buffer is the pointer to your DAC buffer.
- buffer_size is the number of bytes in the buffer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎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.
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-03-17 5:15 AM
Thanks. With SCB_CleanDCache_by_Addr() it works.
