Use this forum to chat about hardware specific topics for the ESP8266 (peripherals, memory, clocks, JTAG, programming)

User avatar
By Jonas F.
#69595
joachim77 wrote:Hi guys,
I wanted to use a I2S microphone SPH0645 with the esp8266. Although I never finished the application (due to lack of time) I had some interesting insights.

First I downloaded and managed to run the "Unofficial Development Kit for Espressif ESP8266". It contains an i2s-full-duplex example that served as a good starting point. I.e. the example sets up a 24 bit i2s-full-duplex-transfer.

One of my main problems when reading the esp8266 technical reference manual was how to adjust the number of bits. I think they just forgot to explain it. Nevertheless the example writes 4 bits to the I2SCONV-register starting at offset 12 (I2S_BITS_MOD_S). That number can go from 0 to 15. With a scope I saw that this changed the bits from 16 to 31. So for 24 bits set the number to 8.

But the spec of the microphone SPH0645 say it requires 32 bits per sample.
Yet for my test it also worked with 31 bits. (It didn't work with 30 bits though.)

So that's it. I hope this might help someone.


Hi Joachim77,
could you share some code to show how to configure the hardware correctly? I understand most of the demo but couldn't get it to work. Maybe i'm missing something.
Thanks in advance.
User avatar
By Jonas F.
#69599 I also noticed that the default defines (I2S_TX_CHAN_MOD for example) differs and are invalid on the Arduino framework on top of the NONOS SDK. So these shouldn't be used or changed as needed.
User avatar
By joachim77
#69902
Jonas F. wrote:Hi Joachim77,
could you share some code to show how to configure the hardware correctly? I understand most of the demo but couldn't get it to work. Maybe i'm missing something.
Thanks in advance.


Hi Jonas,

From the source:
https://github.com/CHERTS/esp8266-devkit/blob/master/Espressif/examples/ESP8266/I2S_Demo/driver/i2s.c
My change:
Code: Select all   SET_PERI_REG_MASK(I2SCONF, I2S_RIGHT_FIRST|I2S_MSB_RIGHT|I2S_RECE_SLAVE_MOD|
                  I2S_RECE_MSB_SHIFT|I2S_TRANS_MSB_SHIFT|
                  (( 26&I2S_BCK_DIV_NUM )<<I2S_BCK_DIV_NUM_S)|
                  ((4&I2S_CLKM_DIV_NUM)<<I2S_CLKM_DIV_NUM_S)|
   /* 15 instead of 8 */      (15<<I2S_BITS_MOD_S)); 


You give very little information. Do you have problems during compile/upload/running?
What serial output do you get? Do you see the correct CS and clock signals with your scope?
If not - on which pins do you look? Which esp8266 board do you use?
User avatar
By joextodd
#72221 Having spent many a long night trying to get this working, I thought I would post my code here in case it helps anyone else. The code will read single channel data from the microphone and output to the Serial Plotter in the Arduino IDE.

Thanks to @cnlohr for the undocumented magic register settings.

https://github.com/joextodd/listener