cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a way for DMA to start to read a buffer in a x position of the array?

YSall.1
Senior

In my current project I am using DMA multi transfer to generate an arbitrary waveform by changing synchronously timers' registers. The first waveform is named "Chrono1", and I would like to interrupt (external) this waveform and insert a second arbitrary waveform that I will name "Chrono2", I already kinda succeeded to interrupt thanks to the push button B1 the current waveform (buffer 1) with another one (buffer 2) by re-initializing DMA with another source buffer, but I would like buffer 2 to be run only one time and then it would get back to the last position in the buffer 1 and resume buffer 1. Do you have a solution for it to resume at the same position of buffer1 after buffer2? Is there a way to start reading a DMA source buffer on a certain x position in the array?

1 ACCEPTED SOLUTION

Accepted Solutions
gregstm
Senior III

I'm not sure exactly what you are doing, but I will reply based on what I think you are trying to do.

I don't think you can start reading a DMA source buffer on a certain x position.

I prefer to use an unchanging timer period driving the DMA (usually sourced from the accurate LSE clock) and update the halves of the DMA circular buffer based on the Half/Complete DMA interrupts. Once started, for reliability and simplicity, I don't fiddle with the DMA rate etc. I regard it almost as a piece of hardware. To create, change, combine waveforms I do it all in software manipulating the wavetables/buffers - you can change the step through multiple wavetables using a fractional step to maintain accuracy, you can interpolate between values of the wavetables if necessary to provide smoother results. If you keep the DMA circular buffer relatively small, the lag before the waveform changes can be kept small.

View solution in original post

3 REPLIES 3
gregstm
Senior III

I'm not sure exactly what you are doing, but I will reply based on what I think you are trying to do.

I don't think you can start reading a DMA source buffer on a certain x position.

I prefer to use an unchanging timer period driving the DMA (usually sourced from the accurate LSE clock) and update the halves of the DMA circular buffer based on the Half/Complete DMA interrupts. Once started, for reliability and simplicity, I don't fiddle with the DMA rate etc. I regard it almost as a piece of hardware. To create, change, combine waveforms I do it all in software manipulating the wavetables/buffers - you can change the step through multiple wavetables using a fractional step to maintain accuracy, you can interpolate between values of the wavetables if necessary to provide smoother results. If you keep the DMA circular buffer relatively small, the lag before the waveform changes can be kept small.

Thank you for your response

Nikita91
Lead II

Some DMA like in F4 or H7 have a "double buffer" mode.

While the circular mode allows only one buffer with a midpoint, the double buffer mode allows to manage as much buffer as necessary, there is 2 memory adresses M0AR and M1AR. When transmitting a buffer, the address of the next buffer can be set freely. Using @Community member​ 's technique one can switch from one signal to another without having to re-write the buffers.