I2S library with Moteino M0

Started by akstudios, January 05, 2022, 07:48:37 PM

akstudios

I'm trying to use an I2S microphone with a Moteino M0. I'm using a Knowles SPH0645LM4H microphone breakout by Adafruit: https://www.adafruit.com/product/3421

Based on Adafruit's tutorial, the data pin on the microphone needs to be connected to pin 9 on an Arduino Zero, which is based on the same ATSAMD21G18 the Moteino is based on. However, it looks like the Moteino uses pin 9 for the radio's interrupt pin (ref here), and this is causing a clash with the I2S library. Things don't work when the setup is wired exactly as the tutorial suggests.

Has anyone else tried using the I2S library with a Moteino? Is there a work around for this? Can I tie the radio's interrupt pin to another pin and change it in the library? I'm unable to find a way to change this in the I2S library.

Felix

The I2S is a hardware peripheral so it can't run on any pins. I'm guessing the peripheral has to be configured in the board variant based on the available pins. I'd need to look more into this for the MoteinoM0 to see if there are any other pins available.
For the MoteinoM0 pin 9 is used by the radio interrupt as you noted.
If you look at the FeatherM0, perhaps that same data pin could be moved to feather pin12/PA19 corresponding to MoteinoM0 pin12/PA19 which is available for use:
https://cdn-learn.adafruit.com/assets/assets/000/046/196/original/Feather_M0_Basic_Proto_v2.2.pdf?1504805559

BUT I am not sure if it will work straight out without more configuration being made.

akstudios

#2
Just wanted to update here:

I changed the I2S pin definition in the Moteino M0 board file which is located in:

C:\Users\Username\AppData\Local\Arduino15\packages\Moteino\hardware\samd\1.6.3\variants\moteino_m0\variant.h

and edited the following line:

#define PIN_I2S_SD          (9u)

Replaced the "9u" with "12u" to point to the other I2S peripheral pin on the SAMD21. I'm now able to get the basic I2S library working with the Moteino and get basic data out of an I2S microphone!

But if we want to do anything more advanced with the Moteino M0 (or an Adafruit Feather M0 for that matter) such as FFT analysis, we have to use a more advanced library such as ArduinoSound. Unfortunately, both the Moteino M0 and the Adafruit Feather M0 use Adafruit_ZeroDMA library in their board definitions, and this always causes a library conflict with the Arduino ones and the code never compiles.

There are a few issues posted around on GitHub regarding this, but I don't see any resolution as of yet. Pretty unfortunate, as it would have been cool to have a Moteino M0 using an I2S mic occasionally take readings and look for a particular frequency or amplitude, and report it over the radio. Using analog mics is likely the way to go for now.