0
\$\begingroup\$

So I want to connecte an i2s MEMS microhpone to a RP2040. I have made a PIO program that looks like this:

.wrap_target
    set pins, 1
    set pins, 0
.wrap

% c-sdk {
// this is a raw helper function for use by the user which sets up the GPIO output, and configures the SM to output on a particular pin

void blink_program_init(PIO pio, uint sm, uint offset, uint pin) {
   pio_gpio_init(pio, pin);
   pio_sm_set_consecutive_pindirs(pio, sm, pin, 1, true);
   pio_sm_config c = blink_program_get_default_config(offset);
   float divider = 20;
   sm_config_set_clkdiv(&c, divider);
   sm_config_set_set_pins(&c, pin, 1);
   pio_sm_init(pio, sm, offset, &c);
}
%}

So very simple. I also adjusted the clock speed so that one cycle would be 333 nS

My problem is that

  1. It seem like the timing is wrong quite frequently. Why could this be? Timing is off at times

  2. I dont get any audio data back from the MEMS microphone, There are something happening but I do not think it should look like this No audio data coming back

Here is my breadboard, note that the colors of the cables corresponds to the logic analyser channel colors My breadboard

These are the cable colors:

Yellow -> I2S, Clock

Green -> LRCL / WS / Frame Select

Blue -> DATA OUT

Any idea where I can start troubleshooting?

\$\endgroup\$
6
  • \$\begingroup\$ Is the sampling rate 16 MHz and square wave being measured 4 MHz? If that's the I2S clock, where is the I2S WS? \$\endgroup\$
    – Justme
    Commented Apr 2 at 18:20
  • \$\begingroup\$ @Justme yes the square wave is 4 Mhz (can be seen in the image from logic analyzer to the right). Green is Word Select. I will update with description of the cables \$\endgroup\$ Commented Apr 2 at 18:36
  • \$\begingroup\$ What is the sampling rate? It is essential knowledge to answer your first question. \$\endgroup\$
    – Justme
    Commented Apr 2 at 18:38
  • \$\begingroup\$ @Justme here is the datasheet: cdn-shop.adafruit.com/product-files/3421/i2S+Datasheet.PDF It states that clock can be between 2MHz and 4MHz. It also states that "Clock frequencies from 2.048Mhz to 4.096MHz are supported so sampling rates from 32KHz to 64KHz can be had by changing the clock frequency." \$\endgroup\$ Commented Apr 2 at 18:49
  • \$\begingroup\$ For the third time, please answer, what is the sampling rate used on the logic analyzer to sample the 4 MHz square wave, is it 16 MHz or some other value? \$\endgroup\$
    – Justme
    Commented Apr 2 at 18:59

1 Answer 1

1
\$\begingroup\$
  1. With the logic analyzer sampling at 12 Msps, each 4 MHz clock period is only 3 samples. It should always look like 33% or 66% duty wave, and the sampling is not synchronous. Expect to see what you are already seeing there, or maybe the clock is slower that 4 MHz if it samples mostly 2 high and 2 low samples per period.

  2. The LRCLK/WS signal is not according to I2S norms or even what the mic requires. It must be a square wave with certain amount of clock cycles high and low.

\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged or ask your own question.