cancel
Showing results for 
Search instead for 
Did you mean: 

SAI config for I2S microphones

DOCon.1
Senior

Hello. I'm looking for information on how to configure I2S microphones using the SAI peripheral. I'm using H743, but this likely applies to any SAIL-capable STM32. The Reference manual, and an application note discuss PDM microphone setup in detail, but have little info on I2S. I'm getting some data output, but it doesn't appear to be correct.

Assumptions

- 48Khz sample speed (Determined by SAI clock speed I think)

- SAI clock speed of 3.072Mhz (I2S standard?)

- 2 Slots

- Channel A

- Master recieve mode, async, stereo. (Only using one mic for now, but will add another)

- Free protocol

- No master clock output

- PDM mode not enabled

- 24-bit data size (Per I2S and the mic)

- MSB first (per mic datasheet)

- Trailing edge polarity (per mic datasheet)

- Oversampling default of /256 (guess ?)

- FS offset first bit (guess?)

- FIFO thresh 1/4 full (So interrupts and DMA triggers at 2 words (L/R channel) out of 8.

- Slot size: 32 bits to hold the 24-bit data.

- Sloten set to 0b11 to enable the first 2 slots.

I tried setting a frame length of 64, and frame-all of 32. (50% duty cycle). I think the frame length of 64 is due to 32 bits x 2 channels, with 32-bit integers used for the 24-bit words. Is this right? Of note... The readings are bogus, and aren't confined to the channel I have selected on the mic (Ie a mix of L, R, and both on the paired DR reads), but if I raise this to 128 length and 64 All, it produces all data on the correct channel. Note that some other value work too, like frame length=62.)

Note from the mic's datasheet: " The Over Sampling Rate is fixed at 64 therefore the WS signal must be BCLK/64 and synchronized to the BCLK". How do I ensure this? A different mic' I've tried datasheet includes this line: "The INMP441 must always have 64 clock cycles for every stereo data-word (fSCK = 64 × fWS)." Is it the same? This more closely maps to the 64-frame-size idea.

I'm using an SAI interrupt to take readings. The readings don't seem right at all, and when I try to DMA it, I get DMA error flags. Does the config look right? Thank you. If I use the frame size of 64, I get underruns after a number of readings. If I raise it higher, the underruns go away, but I think 64 is right.

0 REPLIES 0