davydnorris wrote:OK I can definitely help you with quite a bit of this.
BCK_DIV_NUM, CLKM_DIV_NUM and BITS_MOD work together to set the I2S clock frequency and the number of significant bits in the signal. You have to find the optimal value of all three that's closest to your desired frequency. These are my own notes in my header file so I remember:
The question is more, what limits does Espressif or the I2S module impose on the values. For my desired clock rate, I can choose quite a few ratios between the two, and for now, all of them seem to work. But OTOH Espressif themselves say there are limits, but doesn't clearly state what the limits are.
Note that I2S_CLKM_DIV_NUM must be >5 for I2S data
I have proven this to be not true, with this divider smaller than 5 it still just works, so the I ask myself, where is the real information (by Espressif).
The BITS may be 24bit (bit depth), 31bit (max value in register) or 32bit (value size returned from mic) depending on how it works
The format specifiers only have entries for 8, 16 and 24 bit samples. So I don't know how one is supposed 31 or 32 bit? Or do you mean 2 x 16 bits (two channels)?
#define WS_I2S_CLKM_DIV 13 /* Clock Divisor 5-63 */
I'd prefer to call that the prescaler.
#define WS_I2S_BITS 15 /* Sampling depth-16. Currently needs looking into as it's 4 bits max, which gives 31 bits max?? */
I think the FIFO only allow for one, two or three bytes entries, so that would boil down to 1(?) to 24 bits per sample per channel.
i2c_writeReg_Mask_def(i2c_bbpll, i2c_bbpll_en_audio_clock_out, 1);
This the dreaded binary blob in ROM which I replaced by a source code version I found somewhere, but it's still gobbledeegook.
//Enable FIFO in i2s module
This is where it clearly shows that you copied the Espressif mp3 player example code It has the same flaw. This line does NOT enable the FIFO, instead it DISABLES it (and enables SLC mode).
But apparently you didn't have answers to my questions (comments) in the code I posted. I hope someone else does, but I very much doubt it, I am afraid.