I'm trying to record audio samples to an external flash memory (winbond W25Q128) using Arduino-Zero board and I2S microphone (SPH0645LM4H). To not lose audio samples while writing
to the flash memory (W25Q128), I want to use DMA with I2S as described in Link to github..
My issue is : when I implement the I2S with the DMA, I got nothing in the callback (onI2SReceive) function, i.e. the callback is never triggered.. Could you help me to solve this problem?
I put a simplified version of my code in the following.
#include <I2S.h>
void setup() {
Serial.begin(115200);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
/// Some Code to initiate the flash memory (W25Q128) comes here.
====
I2S.onReceive(onI2SReceive);
// start I2S at 8 kHz with 32-bits per sample
if (!I2S.begin(I2S_PHILIPS_MODE, 8000, 32)) {
Serial.println("Failed to initialize I2S!");
while (1); // do nothing
}
}
void loop() {
}
void onI2SReceive() {
int size = I2S.available();
byte data[size];
I2S.read(data, size);
// Write data to the flash memory!
}