I have interfaced a I2S digital microphone to PIC32MZ controller. I am able to read the digital output from the microphone over I2S-DMA transfer.
Following are the details of my set-up:-
- Controller:- PIC32MZ1024EFE064
- Audio Sensor:- SPH0645LM4H-B
- MPLAB Harmony Configurator (MHC) v2.0.6.0
When I play some tone near the microphone, I get somewhat these values:-
- 0xFA8C8000
- 0xFA8AC000
- 0xFA6EC000
- 0xFA6C8000
- 0xFA600000
- 0xFA544000
- 0xFA6E0000
- 0xFA6AC000
I tried to cover the microphone with glue and tape (so that it does not catch any audio signals), and got the following values:-
- 0xF9DD0000
- 0xF9DD0000
- 0xF9D9C000
- 0xF9D80000
- 0xF9D6C000
- 0xF9D5C000
- 0xF9D4C000
- 0xF9D3C000
- 0xF9D30000
- 0xF9D24000
In the answer to the post Digital Microphone : I2S data output, it is mentioned that the I2S has a rather weird one clock offset compared to the other common formats, and if you get this wrong you will always see a 1 in the MSB of the recovered sample which causes everything to appear negative if interpreted as a signed value.
In my set-up, the MSB is always 1 (or 0xF), no matter what input I give to my microphone. I am planning to use my data to calculate the mean, average and peak-to-peak values. So, the sign-bit is important to me.
Now, I have used MPLAB Harmony to configure my I2S.
My questions are,
- If the one clock offset of the I2S clock is causing the MSB of my data to always be 1, which settings/code should I modify in MPLAB to resolve this issue?
- Apart from the I2S clock issue, what else can be the issues that I must resolve in order to read correct data from my microphone?
Thanks in advance