2021-12-14 08:09 AM
I was wondering.
What will happen when changing/writing data of the memory you assigned as buffer for DMA in circular mode.
Will it be ok, garbage? Is there maybe a shadow register?
Is this for every mem-to-peripheral interface the same?
I'm very curious.
2021-12-14 09:58 AM
It will move whatever you have flushed to memory via write-buffers or cache write-thru.
Typically you'd modify the inactive half of a ping-pong buffer at the HT/TC interrupts.
>>I'm very curious.
Enough to test/evaluate?
2021-12-14 10:02 AM
Nothing special will happen. DMA and MCU core have both access to the memory. (Note that DMA might not have access to all addresses depending on the bus matrix.) The destination peripheral acts in the same way as if the data was written by the MCU.
So if you overwrite the DMA buffer, DMA will use these new values as soon as they were really written to the main memory (beware of caches, depending on core). To know when the time has come to overwrite parts of a DMA buffer, use the completion and half-completion IRQs/callbacks. They let the firmware know, what part of the DMA buffer is safe to write. Data streaming applications use that alot, e.g. for transfering audio packets via DMA.
hth
KnarfB
2021-12-14 10:38 AM
Thanks for the explanation!
Another related question; Is there a way to set an interval for a DMA transfer in circular mode?
It can of course be done in normal mode with a timer interrupt, but isn't there something that can do this in circular mode?
2021-12-14 10:58 AM
Works the same. You have to route a timer update event to a DMA. There was a recent topic here (with a link to code): https://community.st.com/s/question/0D53W00001FltXkSAJ/how-to-use-timer-event-dma-from-memory-to-gpio
hth
KnarfB