Hi All,
I have a Genuino zero hooked up to a digital MEMS mic and currently I am just trying to get the serial output, I get values that are proportional to the input (if I click my fingers or scream into it the numbers all move) andI have also scoped out the connections and signals all seem right except that there is an offset on the output.
The microphone (knowles SPH0645LM4H-B) is 24 bit I2S, 18 bits used, LSBs are 0s. the bits that are changing are 31 >> 18 all other values are 0.
If I shift the numbers down then the offset is approx. -6550, but I cannot for the life of me figure out why the offset is there.
incidentally, using the "arduinosound" libraries yielded different results for essentially the same code, but I have no idea why!
I've been looking at this problem for far too long and the solution is probably staring me in the face but any help/insight much appreciated!
My code is pretty much a copy of the serialplotter example on the arduino site (there is some extra in my attached code which is commented out as I tried to do some manipulation to no avail):
#include <I2S.h>
void setup() {
// Open serial communications and wait for port to open:
// A baud rate of 115200 is used instead of 9600 for a faster data rate
// on non-native USB ports
Serial.begin(115200);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
// start I2S at 8 kHz with 32-bits per sample
if (!I2S.begin(I2S_PHILIPS_MODE, 32000 , 32)) {
Serial.println("Failed to initialize I2S!");
while (1); // do nothing
}
}
void loop() {
sample = I2S.read(); // get an I2S sample
// if it's non-zero print value to serial
if (sample) {
Serial.print(sample, BIN);
Serial.print("\n");
db = 0;
}
}
i2s_sample_code.ino (1.92 KB)