Is DMA memory "atomic"?
Posted: Tue Jul 14, 2020 7:57 am
This question isn't Pi specific, it's more of a general question about DMA. I'm a noob to the concept of DMA, so bear with me. It's difficult to know where to ask such a question, though.
Suppose an MCU implements an ADC, for example. My understanding is that it takes several clock cycles for the MCU to take a reading. It is possible to set up a DMA so that the reading can be put to a memory address. Let's say that the DMA can put a reading there whenever it wants, and continuously updates the contents of the address.
The question is: ignoring latency issues, is the contents of the memory guaranteed to be a "fully formed" reading, and not some value at an "intermediate" state? In other words, can I just read it whenever I want, and know that the reading is "fully formed"?
I guess the same question applies to generating an interrupt on ADC conversion completion instead of DMA. In this case, my understanding is that the MCU will have a fixed address for the reading. But doesn't that reading start to get refreshed immediately? Meaning that the value I read from the address will be wrong?
Suppose an MCU implements an ADC, for example. My understanding is that it takes several clock cycles for the MCU to take a reading. It is possible to set up a DMA so that the reading can be put to a memory address. Let's say that the DMA can put a reading there whenever it wants, and continuously updates the contents of the address.
The question is: ignoring latency issues, is the contents of the memory guaranteed to be a "fully formed" reading, and not some value at an "intermediate" state? In other words, can I just read it whenever I want, and know that the reading is "fully formed"?
I guess the same question applies to generating an interrupt on ADC conversion completion instead of DMA. In this case, my understanding is that the MCU will have a fixed address for the reading. But doesn't that reading start to get refreshed immediately? Meaning that the value I read from the address will be wrong?