Direct Memory Access

Hello again, I just have a quick question regarding the usage of DMA. The way I understand it is
that it allows reading/writing data to the mcu's memory while bypassing the processing resources.
does that mean it would be possible that a micro controller reads , for example, an adc and stores the
result in its memory as a ring buffer repeatedly while a separate mcu reads the memory directly without having to deal with with the first mcu?

Thank you for your time.

Yes, you've got the right idea, but external access to a microcontroller's RAM is pretty rare, usually due to the extremely limited number of pins.

Klagemauer:
Hello again, I just have a quick question regarding the usage of DMA. The way I understand it is
that it allows reading/writing data to the mcu's memory while bypassing the processing resources.
does that mean it would be possible that a micro controller reads , for example, an adc and stores the
result in its memory as a ring buffer repeatedly while a separate mcu reads the memory directly without having to deal with with the first mcu?

Thank you for your time.

Would it be easy to implement or is there a better method of buffering data?

Hi Klagemauer,

Would it be easy to implement or is there a better method of buffering data?

Yes, once you get to grips with the concept, the DMAC programming model is quite easy to implement, but is usually processor specific.

Here are some excellent examples for the Arduino Zero (SAMD21): GitHub - manitou48/ZERO.

1 Like

Does the Zero allow DMA from a non-local device, like another MCU?

Does the Zero allow DMA from a non-local device, like another MCU?

Yes, insofar as it's possible to set up the DMA to perform I2C, SPI and serial transfers.

The DMA can perform not only memory transfers, but also read and write to peripheral registers and be triggered by peripheral interrupts. This includes the ADC, DAC, SERCOM modules and TCC/TC timers.

The DMA is really useful for any situation that involves moving data from memory to memory, peripheral to memory and memory to peripheral without the need for processor intervention. The transfer occurs in parallel with the code in your sketch.

In addition, on the Zero you've got 12 DMA channels with an arbiter to control transfer priority, so it's possible to kick-off more than one transfer at a time.

Can you set up DMA to/from a set of IO pins, in a sort of traditional strobed "I've put data on these pins, and here's a signal to indicate that it's valid, so transfer that to/from memory" scheme? From brief reading of the datasheet, it looks like DMA to "ports" should be possible, but it was far less obvious whether you could get the sort of handshaking ancient devices expect...

The DMA is really useful for any situation that involves moving data from memory to memory, peripheral to memory and memory to peripheral without the need for processor intervention.

DMA (Direct Memory Access) is the concept/scheme. To implement it, there is a need of a sophisticated hardware called DMA Controller something like the old Intel's 8257. Arduino DUE supports DMA, and it has built-in DMA Controller.

1 Like

westfw:
Can you set up DMA to/from a set of IO pins, in a sort of traditional strobed "I've put data on these pins, and here's a signal to indicate that it's valid, so transfer that to/from memory" scheme? From brief reading of the datasheet, it looks like DMA to "ports" should be possible, but it was far less obvious whether you could get the sort of handshaking ancient devices expect...

My limited experience is with the STM32F103 stuff so may not be universal, but I would guess is typical.

The DMA controller does handshaking with the internal peripherals, e.g. does a transfer each time an ADC conversion becomes valid in ADC continuous conversion mode. Similarly one can stream data to/from GPIO ports either at a fixed rate or on events that might be handled by an interrupt, such as a pin state change. I don't think there's a way to send a value to a port and twiddle individual bits on control lines as might be needed to service an external parallel RAM all under the DMA controller.

MrMark:
I don't think there's a way to send a value to a port and twiddle individual bits on control lines as might be needed to service an external parallel RAM all under the DMA controller.

With a DUE, you can read continuously or not, via an AHB DMA, the content of PIO_PDSR (up to 32 bits = 32 pins), or continuously or not write, via an AHB DMA, to PIO_ODSR (up to 32 bits = 32 pins).

Thank you for your replies. I am currently trying to learn more about DMA.
Do you by chance know what the difference between DMA and streaming DMA is?

Klagemauer:
Hello again, I just have a quick question regarding the usage of DMA. The way I understand it is
that it allows reading/writing data to the mcu's memory while bypassing the processing resources.
does that mean it would be possible that a micro controller reads , for example, an adc and stores the
result in its memory as a ring buffer repeatedly while a separate mcu reads the memory directly without having to deal with with the first mcu?

Thank you for your time.

If you want to do "stuff" while concurrently doing A/D readings, simply use an interrupt to call the A/D every "X" number of time intervals you need.

westfw:
Can you set up DMA to/from a set of IO pins, in a sort of traditional strobed "I've put data on these pins, and here's a signal to indicate that it's valid, so transfer that to/from memory" scheme? From brief reading of the datasheet, it looks like DMA to "ports" should be possible, but it was far less obvious whether you could get the sort of handshaking ancient devices expect...

The external RAM interface may be able to be persuaded to do this, but to me it seems like too much work and too may pins wasted to implement a "high speed" protocol on a 16 mhz chip......

Don't know about doing DMA to ports though... considering the horrible Harvard architecture it uses. The external memory interface connects to the "ram" side of the Harvard wall. The ports are on the other side, accessible only with special registers - don't see how DMA could "get through" that.

krupski:
If you want to do "stuff" while concurrently doing A/D readings, simply use an interrupt to call the A/D every "X" number of time intervals you need.

I will use multiple stm32f0's in parallel which are controlled via external interrupts to start each sampling interval. I was hoping that I could reduce potential bottle-necking by allowing the MCU to just sample and buffer while leaving the relaying of the data to the DMA.