STM32F4 – DMA with bigger steps

dmamicroprocessorstm32stm32f4

I'm programming an STM32F4 Discovery board to push a sequence of 12 bit values into the DAC data register. This works well using timer interrupts: inside my IRQ handler, I have code that looks like:

phase += phaseIncrement;
DAC_SetChannel1Data(DAC_Align_12b_R, function[phase]);

and the output of the DAC looks like I think it should. Note that phaseIncrement doesn't have to be 1 – if I want a high frequency output, I can skip points in function[], sacrificing the accuracy of the signal for a bit of extra speed.

Now, I am reading about DMA. It looks like the STM32F4 can only increment by one of three amounts – 1 byte, 2 bytes, and 4 bytes, depending on the size of the variable being transferred. Is this correct? Is there a workaround that will let me skip some of these memory addresses so that I can emulate my current output without less CPU usage?

Best Answer

As far as I know the STM32F4's DMA controller cannot do what you want. DMA can feed the DAC much faster than interrupt driven software (up to 10.5 Msps) so you might not need to skip samples anyway.

If DMA is not fast enough then the classical solution is to make multiple copies of your waveform, each with half as many samples as the previous one. This will use a maximum of twice as much sample memory (1 + 1/2 + 1/4 + 1/8 etc). If you have several waveforms that take up a lot of space then you might not have enough memory to store all the higher octaves. However if you only need to play one waveform at a time then you may still have enough RAM to precompute and store the octave(s) required for just the current waveform.

Related Topic