PDM microphone L/R GPIO pin.

iamflimflam1
Posts: 14
Joined: Fri May 22, 2020 7:58 am

PDM microphone L/R GPIO pin.

Postby iamflimflam1 » Wed Sep 24, 2025 4:55 pm

I'm using a PDM microphone - https://media.digikey.com/pdf/Data%20Sh ... -S261F.pdf

This has a clock pin and an L/R pin.

When I'm setting up the GPIO pins - I don't see any way to specify the L/R pin.

Code: Select all

typedef struct {
    gpio_num_t clk;                                     /*!< PDM clk pin, output */
    union {
        gpio_num_t din;                                 /*!< DATA pin 0, input */
        gpio_num_t dins[SOC_I2S_PDM_MAX_RX_LINES];      /*!< DATA pins, input, only take effect when corresponding I2S_PDM_RX_LINEx_SLOT_xxx is enabled in i2s_pdm_rx_slot_config_t::slot_mask */
    };
    struct {
        uint32_t   clk_inv: 1;     /*!< Set 1 to invert the clk output */
    } invert_flags;                /*!< GPIO pin invert flags */
} i2s_pdm_rx_gpio_config_t;
Not setting it to anything seems to work fine - I get audio data.

But I am slightly confused as to why there is no way to set the L/R pin.

MicroController
Posts: 2663
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: PDM microphone L/R GPIO pin.

Postby MicroController » Wed Sep 24, 2025 6:06 pm

The L/R pin is a configuration input of the microphone. You connect it directly to VDD or GND as desired and then leave it there. It's not something that'd need to be controlled by the I2S master at any point. See "9. APPLICATION CIRCUIT (FIGURE 4)" on page 7 of the document you linked.
In "7. I/O TIMING DIAGRAM" you can also see that the level on the L/R pin ("SEL") defines at which clock phase the microphone outputs data or goes high-z. It is designed in this way so that you can connect two of these microphones, one "left" and one "right", to the same clock and data line without additional circuitry to get 2-channel/stereo sound.

You should probably not leave the L/R pin unconnected/floating.

iamflimflam1
Posts: 14
Joined: Fri May 22, 2020 7:58 am

Re: PDM microphone L/R GPIO pin.

Postby iamflimflam1 » Sat Sep 27, 2025 6:50 am

Thanks - that’s really helpful. Makes sense now.

Who is online

Users browsing this forum: Barkrowler, Bing [Bot], PerplexityBot and 4 guests