Hi all!
I'm implementing a very similar system to this example, which outputs a sine wave using the DMA. But, I'd like to be able to repopulate the source buffer with different wave forms. When I do this, about half of the time, it works perfectly, but the other half of the time, the output waveform contains many (or mostly) random values.
My method for repopulating the table is based off a simple Direct Digital Synthesis (DDS) algorithm, and copies the new waveform in from a lookuptable (LUT):
Any ideas what might be causing this?
I'm implementing a very similar system to this example, which outputs a sine wave using the DMA. But, I'd like to be able to repopulate the source buffer with different wave forms. When I do this, about half of the time, it works perfectly, but the other half of the time, the output waveform contains many (or mostly) random values.
My method for repopulating the table is based off a simple Direct Digital Synthesis (DDS) algorithm, and copies the new waveform in from a lookuptable (LUT):
Code:
int place = 0;
for(int i = 0; i<bufferlength; i++) {
sourcebuffer[i] = LUT[place];
}
place = place + M; //M is the tuning word, used to skip through the lookup table to change output frequency
if(place >= lengthLUT) {
place = place - lengthLUT;
}
}
dma.sourceBuffer(sourcebuffer, sizeof(sourcebuffer));
Any ideas what might be causing this?