I2S Channels breaking after making unrelated changes

sambreott

Member
Just some background:
Specs: Teensy 4.1, Teensyduino 1.62.0
Tools: PlatformIO (teensy platform, teensy41 board, arduino framework)
Add-ons: teensy-4-usb-audio (https://github.com/alex6679/teensy-4-usbAudio) [Adds usb serial inputs and outputs to teensyduino audio library]

My issue is a bit of a complex one. My teensy 4.1 has 4 channels and a playMemory as I2S/memory inputs going to an 8-channel usb output, as well as 2 channels of usb input going to the 2nd I2S bus as output. The teensy also serves the function of collecting EEG data from an AFE with SPI and to send out the EEG over serial. It was originally sent in JSON packets using ArduinoJSON, and with this setup, there were no issues with any audio channels. I changed the EEG data format to be binary c struct packets without any padding to speed up the sending process, but after making the change, the audio broke down. When I take a recording now, channels 1-3 are muffled, almost sounding filtered as well. At first glance, channel 4 stopped functioning completely, but it actually receives a very small constant value. Channel 5 functions fine, but that is to be expected as it comes from memory rather than I2S.

One thing I have tried is increasing my AudioMemory value, but even with pretty big overhead this did not fix the issue. I have also tried changing my patchcording around, which produced some interesting results. I shifted the patchcord destination values up 1 (01234 to 12345), and channel 1 started functioning properly, but channels 2-4 were showing the same muffled/filtered effect from before. After this, I tried shifting the patchcord destinations to the top end of the bus (ch 4-8), and there was a similar combination of semi-functional and dysfunctional channels. I had a sneaking suspicion it had something to do with overloading the serial bus, so I tried commenting out the I2S2 section, but this did not fix the issue.

I have attached my teensy code file below. Thank you guys in advance for the help!
 

Attachments

  • main.cpp
    6.4 KB · Views: 25
Try omitting `Serial.send_now();` for now. That forces the data to be sent even though it’s by no means necessary—the USB buffer can hold much more - this slows down everything. It's worth a try.

I also notice that pin 7 is being used (okay, that must have been the case before as well—but it might still be an (additional) error).
Isn’t pin 7 used by AudioInputI2SQuad i2s1? Check that out.
 
Try omitting `Serial.send_now();` for now. That forces the data to be sent even though it’s by no means necessary—the USB buffer can hold much more - this slows down everything. It's worth a try.

I also notice that pin 7 is being used (okay, that must have been the case before as well—but it might still be an (additional) error).
Isn’t pin 7 used by AudioInputI2SQuad i2s1? Check that out.
Thank you for the pointer about Serial.send_now(), that definitely was the software issue. I had a sneaking suspicion it would be a one line fix to my weeks long struggle lol. It turns out in addition to that, some of the port holes for the mics on the custom pcb got plugged with solder, which led to the seemingly random combination of muffled channels. After testing with an unobstructed board, I can confirm that the audio now works as intended.

As for the pin issue, I'll have to consult the hardware person on my team, they're the one who designed the schematic and custom pcb.
 
Back
Top