• INMP441 readout on RP2040

    biemster10/25/2022 at 15:22 4 comments

    So I have chosen the arduino-pico environment for this project. SPI is quite straightforward to work with, but keep in mind that the LRCLK (=WS) has to go on pin BCLK +1 due to limitations on the PIO in arduino-pico.

    The SPI is setup like this:

    #include <I2S.h>
    
    I2S i2s(INPUT);
    int32_t l, r, sample;
    
    void setup() {
      pinMode(1, OUTPUT); // L/R
      digitalWrite(1, LOW); // LOW=LEFT, HIGH=RIGHT
      
      i2s.setDATA(29);
      i2s.setBCLK(3); // LRCLK = +1
      i2s.setBitsPerSample(24);
      i2s.begin(16000);
    }

    and after this can be read out:

    void loop() {
      i2s.read32(&l, &r);
      sample = l ? l : r;
      Serial.printf("%.6x\n", sample);
    }

    This will output 3byte 24bit samples on the UART, which can be played back on a Linux machine using the following commands:

    $ cat /dev/ttyACM0 | xxd -r -p | aplay -r16000 -c1 -fS24_3BE

    The call to xxd turns the hexadecimal samples into raw bytes.

    This code and the pin diagram is available in https://github.com/biemster/arduino-pico-serialmic

  • C-SDK, arduino-pico or MicroPython

    biemster10/25/2022 at 15:02 0 comments

    There are no less then three very well supported ways to program a Raspberry Pi Pico, all with a great and active community:

    1. The official bare C-SDK
    2. arduino-pico, based on the C-SDK, but using the familiar .ino sketches.
    3. MicroPython / CircuitPython

    So first thing is to decide which one to use in this project. The two main requirements are SPI input for the INMP441, and the ability to use https://github.com/kingyoPiyo/Pico-10BASE-T for sending the audio frames over Ethernet.

    Funny thing is, the 10BASE-T code by kingyoPiyo is written for the C-SDK, and only arduino-pico and MicroPython have SPI input! (the SPI code in the C-SDK is output only as of yet)

    So for now I have chosen to go with arduino-pico, since it should be relatively straightforward to use the 10BASE-T code as a library in Arduino. I've never done this before, so keep your fingers crossed.