So, I tried using Teensy 4.0 OUT1/IN1 for I2S audio and OUT2/IN2 for TDM audio and I am having a problem. The TDM port seems to work fine and the I2S output works fine. However, when I try to enable I2S input, it causes the TDM input waveform to be completely wrong. What is going on? I cut down my code to having a simple loopback wire from OUT2 to IN2. Here's my code:
#include <Arduino.h>
#include <Audio.h>
AudioInputI2S i2s_in; // if this is commented out, everything is ok
AudioOutputI2S i2s_out;
AudioSynthWaveform waveform1;
AudioInputTDM2 tdm2_in;
AudioOutputTDM2 tdm2_out;
AudioControlSGTL5000 sgtl5000_1;
// TDM2 OUT2 (pin 2) is wired to TDM2 IN2 (pin 5)
AudioConnection patchCord1(waveform1, 0, tdm2_out, 0);
AudioConnection patchCord2(tdm2_in, 0, i2s_out, 0); // left output
AudioConnection patchCord3(tdm2_in, 0, i2s_out, 1); // right output
void setup()
{
AudioMemory(40);
pinMode(LED_BUILTIN, OUTPUT);
sgtl5000_1.enable();
sgtl5000_1.lineOutLevel(13); //
waveform1.begin(WAVEFORM_SINE);
waveform1.frequency(200); // frequency of the sinewave
waveform1.amplitude(0.05); // turn on the waveform
}
void loop()
{
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on
delay(1000);
digitalWrite(LED_BUILTIN, LOW); // turn the LED off
delay(1000);
}
For this bit of code, I'm using the Teensy Audio Shield (for Teensy 4.0), I'm adding a short jumper wire from pin 2 to pin 5, and then listening to the audio on line out signals. The output sine wave is completely messed up with some big discontinuities. But, if I comment out "AudioInputI2S ", then the sine wave is fine. Any ideas on what could cause this?