cancel
Showing results for 
Search instead for 
Did you mean: 

DAC in DMA mode @ enabled cache

LeonidP
Associate II

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?

 

2 REPLIES 2
ahsrabrifat
Associate III

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.

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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..