Input Devices

This week I have been really interested by in I2S because it scares me. I do not know much about audio, and I want to learn more about how to store it. So for this week the goal was to get an data from an i2s mic up and running

First I started by the using the samd21 xiao because I wanted to eventually connect it to a speaker, and the SAMD21 has a built in DAC. The SAMD21g which is the chip that the samd21 xiao uses also has i2s bus that I could use. However, upon trying use the connect the mic to xiao and use the i2s library I got this error message

However after looking at the atsamd21 datasheet and samd21 xiao schematic, I saw that the pins associated with the i2s bus were on the xiao (D2, D3, and D8). So after some research I saw that I could modify a the core for the samd21 xiao and specifically a file called variant.h in the seeeduino xiao folder (how I found arduino core files) Following the example from other samd21 board variant.h files I put this code into the samd21 xiao core.

After making those changes I was able to get a reading from the microphone which was reactively to the sounds around it

However, there was a big problem which is that the samd21 xiao would stop taking readings from the mic after roughly a minute or so. I was stuck trying to fix this problem for most of this week to no avail. First, thing I tried was looking more into the samd21 xiao core, so I started looking through the I2S library that comes with the samd21 xiao looking for something buffer that might be overflowing. However, that journey did not turn up any leads. Then I talked to Quentin about my issues and he suggested that I try using the fab sam core, because it by default allows for I2S communication, and just upload to the xiao like it is a generic samd21g. However, the pins that Quentin's core broke different pins for I2S than I had used in my previous example. However, the other pins he used were also on the xiao, so I tried those and had luck, and then tried the pins I had originally used and had no luck as well. I know that Quentin's strategy definitely can work, but it seemed to me that their were other nuisances in the samd21 xiao core, compared to Quentins, that allowed I2S to work on the pins that I had selected. So I then thought maybe I could try and compare both cores side by side and try and figure out why I could get a mic partially working with one core and not the other and then maybe through that process I would gain more insight that would help me fix this problem. Then I had the realization that it was now in fact Tuesday, and I need to stop my obsession with samd21 xiao

So at this point I pivoted to using the rp2040, which seems much easier to use. The xiao rp2040 does allow for i2s by default using PIO, so it can be used on any set of pins. Then I designed this board which would allow me to interface with a mic and save it to an SD card.

While there were no shorts in this with this board, and there was continuity between the pins I wanted to be connected to and there was not contuinity between the pins that I did not want to connect to. The board still did not work, so as a last ditch effort I connected the mic directly to xiao and I was able to get a result and the rp2040 did not crash which was great

This is very far from what I wanted to accomplish this week, but I think the biggest thing to note about this week is stubborness. I was so obssessed with the seeeduino xiao because it had a DAC and i had this dream of reading from a mic and playing a speaker all on one controller. Even though this solution was much harder than using a different microcontroller and an external DAC. At a certain point I had invested so much time that I felt that I just had to see it through which was a mistake. So in general, I just need to be less stubborn and also be more mindful with my time.