Friday, 14 August 2015

pic - PIC32MZ: MSB of I2S data from digital microphone is always high


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:-



  1. Controller:- PIC32MZ1024EFE064

  2. Audio Sensor:- SPH0645LM4H-B

  3. 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,



  1. 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?

  2. 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



Answer




Your MSb is likely set because the electrical signal entering the ADC has a significant DC offset from the mid-point of the ADC. Try capturing data points and "viewing" the signal graph when there are periods of quiet and periods of high levels of sound present. If necessary capture some data and view it in excel or something similarly usable to graphically view the data.


Your microphone has a sensitivity of -26 dBFS per RMS pascal (94 dB SPL) at 1 kHz. So with an RMS sound pressure level of 94 dB at 1 kHz I would expect a digital reading of -26 dB compared to full scale. -26 dB is about 5% of full-scale so, if you are expecting the microphone to produce a big audio signal that might have a relatively small DC offset, please consider this as unlikely; your digital audio signal will be small and "sat" on top of a large digital DC offset.


No comments:

Post a Comment

arduino - Can I use TI's cc2541 BLE as micro controller to perform operations/ processing instead of ATmega328P AU to save cost?

I am using arduino pro mini (which contains Atmega328p AU ) along with cc2541(HM-10) to process and transfer data over BLE to smartphone. I...