Hi! I'm new to DMA and need some help to understand how I can achieve the following:
I'm using the Arduino_AdvancedAnalog library and the Giga board. I'm trying to learn some basic audio generation/processing and not sure how I should set up my code. I have gotten the examples to output sound but all the examples needs to poll dac.available() in the main loop. As my project grows I need the filling of the DMA buffers to be interrupt based and do the processing in blocks/buffers so the cpu can handle other stuff in between.
So basically what I want to achieve is to continuously output sound at 44.1kHz in a block/buffer based way. I understand I need two use two buffers, while buffer0 is being sent to the DAC using DMA buffer1 gets filled with new samples, when buffer0 completes the transfer buffer1 starts it's transfer while buffer0 is now being filled with the next block of samples.
Should I set up a timer interrupt in exact microseconds that triggers my processAudio() and then call the Dac.write() function from the AdvancedAnalog library?
Or is there a way to have the DMA transfer function trigger an interrupt that calls the processAudio() function every time it starts a transfer of a new buffer? So I can make sure that the next sample buffer is generated/calculated before it's time to send it to dac?
All my processAudio() function should do for now is generate a sinewave in blocks of 32 samples. This I know how to do with keeping track of the phase etc.
I'm I on the right track or is there another way this is usually done?
Thanks!