2

Attached is an image from the analyzer. I am afraid that the I2S is shifted one bit, because as it stands, the MSB bit is always high, all samples come back 0x3nnnn (18-bits, so MSB bit is on the left). 2's complements format would indicate they are all negative.

Analyzer is set up per microphone documentation, sampling at clock falling edge. By the way, the PIC, which I am using, is getting the same data in RAM buffer, as the analyzer. Yes, maybe I set them both same wrong. But this question is not about PIC, it is about understanding this specific microphone data format.

enter image description here

EmbeddedGuy
  • 548
  • 2
  • 15
  • 1
    A one bit delay is indeed a common I2S setting option. Look at the configuration choices for your sender and receiver - word length, justification, bit delay, etc. – Chris Stratton Aug 30 '20 at 17:29

1 Answers1

2

There is actually nothing wrong, I just did not take enough samples. I have read others to ask the same question, I guess they also did not look deep enough into sampling. The microphone seems always to start with negative numbers after power up. And first few samples are 0x0000, as the microphone is powering up.

The microphone data was going up towards its lowest binary value of 0x3FFFF (which is approaching the zero from the negative side in decimal world), and after about 600 samples the values reached zero, thus flipped the sign. See the attached picture. So the previous scope picture above seems to show a correct decoding after all.

Note that my processing changes the original 18-bits to 16-bits to save memory. Mic had max at 0x3FFFF, I have now the max at 0xFFFF, but it has nothing to do with the MSB bit, it does flip to positive.

enter image description here

Next step was to convert the two's complement to be only positive. I simply wanted to add an offset of 'half-way through', which in case of 16-bits is 0x8000:

*(audio_data + i) = 0x8000 + data_from_mic; // change values up to a positive world!

As I do not need the resolution, I only record every 40th sample from the I2S. After this the data looks human-understandable. See the recording of 1000 samples (2 seconds), saying word "Hey!" and a clap with hands. Notice, how after the power up, the mic starts with above mentioned zero level, then likely auto-detects the external volume and settles to middle/zero level:

enter image description here

Hopefully this helps someone.

EmbeddedGuy
  • 548
  • 2
  • 15
  • The initial overshoot is the mic FET current source and supply coupling cap charging up to DC. The clap is saturating and clamp charging the cap with a slow decay as echos off the wall modulate the return to "xV dc" reminds me of mid '80s when my buddy musician had the famous "Hey" rocker sound on a chip for his drum machine. – Tony Stewart EE75 Sep 02 '21 at 03:10