##Fix listed below##
Attempting to get a clean I2S signal out from an inmp441 board but kind of stuck. I know it may not be officially supported as I2S on the SAMD21 variant seems to have been disabled from factory.
I am able to get I2S to initialized and audio recorded with either the variant included I2S library and AdafruitZero I2s library.
I am experiencing the audio signal coming in with also many zeros in a row being thrown in the serial monitor. I have constant noise happening in the office so I think it has something to do with the buffered data or the 16 bit shifting from 32bits. Programming isn’t my expertise but cant seem to find much support on the topic.
If I code in the following, serial output does not occur at all.
i2s.read(&sampleL, &sampleR);
micIn = sampleL; // Read in
if(micIn == 0) return;
Any help or direction would be greatly appreciated. I like this board for the projects I need that don’t require wifi/BLE. Will calculate fft data and drive LEDs once I can clean up the incoming signal.
Code:
// For testing this library with the INMP441 with the Xiao SAMD21
#include <Adafruit_ZeroI2S.h>
#define SAMPLING_FREQ 30000
int32_t sampleL = 0;
int32_t sampleR = 0;
int16_t sample = 0;
uint8_t squelch = 100;
Adafruit_ZeroI2S i2s;
void setup() {
Serial.begin(115200);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
i2s.begin(I2S_32_BIT, SAMPLING_FREQ);
i2s.enableRx();
}
void loop() {
// put your main code here, to run repeatedly:
getSampleI2S();
}
void getSampleI2S() {
//
int32_t micIn;
if(i2s.rxReady()) {
i2s.read(&sampleL, &sampleR);
micIn = sampleL; // Read in
sample = micIn >> 16;
//------------ Oscilloscope output ---------------------------
Serial.print(sample); Serial.print(" ");
Serial.print(1500); Serial.print(" ");
Serial.print(-1500); Serial.print(" ");
Serial.println(" ");
}
}