Teensy 4.1 and 4-channel audio (AudioInputI2SQuad)

chipaudette

Well-known member
I'm still trying to get my T4.1 (beta) to do 4 channel audio using two of the RevD Teensy Audio Shields. I'm successful in getting audio output of the system, but I can't seem to get audio into the system. Has anyone successfully gotten 4 channels of audio into their T4.x using I2S?

To get Quad audio working with the Teensy Audio boards, one needs to modify the second board. Similar to this post, here are the modifications that I performed:

* Cut the trace between the two pads for the audio board's RX (Pin 7)
* Cut the tracce between the two pads for the audio board's TX (Pin 8)
* Remove the 10K resistor connected to Pin 6
* Add a wire from pin 6 over to the pad that had been connected to pin 8
* Add a wire from pin 32 to the pad that had been connected to pin 7
* Cut the trace between the 3 pads that set the audio shield's address (was LOW)
* Solder-bridge the center pad to the other pad (sets the address to HIGH)

For software, I loaded up the Audio library example sketch PassThruQuad. This sketch is set to route audio that is input (line-in) into one board and send it to the output (headphone) of the other board. This seems like a good test of my setup.

So, my setup is one T4.1 (beta) plus one unmodified audio board (board #1) plus one modified board (board #2). With this setup, I am successful with injecting audio into board #1 and hearing it from board #2. So, the output of my modified board is fine. But, I am not successful with injecting audio into board #2 and hearing it from board #1. So, the input of my modified board is not working.

[By rerouting the connections, I've confirmed that the output of the unmodified board does work. The only thing that doesn't work is the input to the modified board.]

Since user error is always the best answer, I removed my modified board and inserted a different board that I modified. I got the same negative result. While user error is still a possible answer, now I am suspecting the software.

Has anyone successfully gotten quad audio input to work via I2S on their T4.1? What connections did you use? Was there a trick?

Chip
 
Last edited:
Hi Chip, when I click on the attachments I get this error:

popup.PNG

Using Chrome on Windows 10.

Regards,
Paul
 
Hi Chip, when I click on the attachments I get this error:

Using Chrome on Windows 10.

Regards,
Paul

Odd GONE now - they were there before ... they linked to new page - not attached pics.

Using updated (chrome) Edge in Win 10
 
Hi Chip,
I sketched out the different connections and it seems like you have all the pin numberings OK. The mods also look OK.
Yes, I would remove the CS pull-up resistor on pin 6 of both audio boards. Not sure whether the audio data on pin 6 likes both pull-ups in parallel.

Did you perhaps put a scope on pin 6 [the input from the 2nd modified audioboard, a.k.a. the yellow wire]? Do you see an active signal there?
Capture.PNG

Oops, noticed an inconsistency.
From the Audio System Design Tool, i2s_quad1:
Capture2.PNG
But the pin card shows pin 5 to be the input:
Capture3.PNG

Could that be the problem?

Regards,
Paul
 
In order to find out whether pin 5 or pin 6 is the correct input pin, I checked the schematic and the immense i.MX RT1060 manual.
Teensy 4.1 schematic [pin numbers & pin names highlighted]:

Capture5.PNG

and then find the corresponding pin names in the manual:

Capture4.PNG

I guess now it comes to how all those pins are multiplexed for InputI2SQuad operation...that's beyond my knowledge.

Paul
 
Hi Chip,
I sketched out the different connections and it seems like you have all the pin numberings OK. The mods also look OK.
Yes, I would remove the CS pull-up resistor on pin 6 of both audio boards. Not sure whether the audio data on pin 6 likes both pull-ups in parallel.

Did you perhaps put a scope on pin 6 [the input from the 2nd modified audioboard, a.k.a. the yellow wire]? Do you see an active signal there?
View attachment 20360

Oops, noticed an inconsistency.
From the Audio System Design Tool, i2s_quad1:
View attachment 20358
But the pin card shows pin 5 to be the input:
View attachment 20359

Could that be the problem?

Regards,
Paul

According to the source code it defaults to pins 8 and 6.
Code:
#elif defined(__IMXRT1062__)
	const int pinoffset = 0; // TODO: make this configurable...
	AudioOutputI2S::config_i2s();
	I2S1_RCR3 = I2S_RCR3_RCE_2CH << pinoffset;
	switch (pinoffset) {
	  case 0:
		CORE_PIN8_CONFIG = 3;
		CORE_PIN6_CONFIG = 3;
		IOMUXC_SAI1_RX_DATA0_SELECT_INPUT = 2; // GPIO_B1_00_ALT3, pg 873
		IOMUXC_SAI1_RX_DATA1_SELECT_INPUT = 1; // GPIO_B0_10_ALT3, pg 873
		break;
	  case 1:
		CORE_PIN6_CONFIG = 3;
		CORE_PIN9_CONFIG = 3;
		IOMUXC_SAI1_RX_DATA1_SELECT_INPUT = 1; // GPIO_B0_10_ALT3, pg 873
		IOMUXC_SAI1_RX_DATA2_SELECT_INPUT = 1; // GPIO_B0_11_ALT3, pg 874
		break;
	  case 2:
		CORE_PIN9_CONFIG = 3;
		CORE_PIN32_CONFIG = 3;
		IOMUXC_SAI1_RX_DATA2_SELECT_INPUT = 1; // GPIO_B0_11_ALT3, pg 874
		IOMUXC_SAI1_RX_DATA3_SELECT_INPUT = 1; // GPIO_B0_12_ALT3, pg 875
		break;
	}
IN2 corresponds to I2S2.
 
Thanks vjmuzik, it makes sense now.
So could you call pin 7 also IN1A, pin 6 IN1B, pin 9 IN1C and pin 32 IN1D ? [similar to the OUT1A/B/C/D names]
Is this somewhere documented besides the source code?

Paul
 
I believe Pin 7 is Output only, pin 8 is Input only, but 6,9, and 32 can be either or, the only mention I can remember is somewhere in the beta thread probably.
 
OK. I came to my assumption when I looked at the description of the AudioInputI2SOct object:

Capture.PNG

But perhaps it's a bit more complex...

Paul
 
Hi vjmuzik, you are right, 7 is output only, 8 is input only, 6, 9 and 32 can be either or.

Capture2.PNG

Paul
 
Thanks for all the deep digging!

I did remove the one board's 10k resistor and it didn't work. I'll try removing the other board's resistor. Good idea. Sadly, I'm separated from my hardware and won't be back to it until Monday.

Have any of you ever gotten this to work yourselves with T4 or T4.1?
 
Both boards now have their 10K resistor removed. Sadly, I'm still not able to get the 2nd audio board to acquire audio. :(

T4 Quad.jpg

Any other suggestions for something that I can try?

Or, if no one has ever demonstrated quad I2S on the T4.x, is it possible that the audio library support is still not correct?
 
Hi Chip,
The next step I would do is connect an oscilloscope to pin 6 of the Teensy and check for digital data.

If you see data, then you know the modified audio adapter is fine and there is perhaps something with the audio library not correct.

If you see either a low or high level at pin 6, then lift/disconnect the yellow wire from pin 6 and measure on the other end of the wire [on the pad].

Capture.PNG

If you now see data on the pad then software is pulling pin 6 to a low or high level.

By the way, I assume that you are running this sketch [url]https://github.com/PaulStoffregen/Audio/blob/master/examples/HardwareTesting/PassThroughQuad/PassThroughQuad.ino[/URL] unmodified?

Question: what does this little white wire on pin 3V3 connect to?

Paul
 
The little white wire runs to the voltage regular on the 4.1 beta boards all of them are like this because of a manufacturing error some of the power and ground pads weren’t connected.
 
Ah OK, I did not see that wire on my T4.1 production board, hence my question.

Thanks,
Paul
 
Quad I2S seems to work fine

Hi Chip,

In order to check whether pin 6 is actually properly routed for I2S input data, I tried the setup below succesfully [without using audio adapter boards].
In the Audio System Design Tool I placed and routed a USB input block and the I2Squad blocks as follows:

Untitled.png

Externally I wired channel 1&2 output [pin7] to channel 3&4 input [pin 6]. Channel 3&4 output [pin 32] is wired to a PCM5102 board. The USB port is connected to a laptop providing audio [Teensy is acting as USB sound card].

I2Squad test.jpg

With the following code it works perfect:
Code:
// PCM5102 bd   Teensy 4.x
// VCC          Vin          
// GND          GND
// LRCK         20 
// DATA         32        TX-out
// BCK          21 
// --           23        MCLK, not used by PCM5102 bd
// Teensy 4 pin 7 [TX-out] to pin 6 [TX-in]

#include <Audio.h>

AudioInputI2SQuad        i2s_quad1;      //xy=241,295
AudioInputUSB            usb1;           //xy=248,208
AudioOutputI2SQuad       i2s_quad2;      //xy=514,252
AudioConnection          patchCord1(i2s_quad1, 2, i2s_quad2, 2);
AudioConnection          patchCord2(i2s_quad1, 3, i2s_quad2, 3);
AudioConnection          patchCord3(usb1, 0, i2s_quad2, 0);
AudioConnection          patchCord4(usb1, 1, i2s_quad2, 1);

// set Tools > USB Type to Audio

void setup() {
  AudioMemory(12);
}

void loop() {
}

To be sure I2S data is indeed routed via pin 6 and 7, I lifted the blue wire while playing audio: the audio stops.
Inserting the blue wire again restored the audio.

So it looks like the audio library is fine for I2Squad [at least, input pin 6 works OK].

Were you able to hook up an oscilloscope to pin 6?

Paul
 
I tested this today. It seems to work fine.

To test, I used 4 PWM pins and with 10K resistors and 0.1 uF capacitors to as low-pass filters, to create 4 distinctive test waveforms. I connected those 4 waveforms to the 4 inputs on 2 audio shields. Then I ran a modified copy (to turn on the PWM) of the PassThroughQuad example.

Here's the hardware setup:

DSC_0869_web.jpg

This is what my oscilloscope sees for the 4 outputs:

file.png

It seems to be working as intended. You can see the frequencies and duty cycles of each waveform matches the code below. You can also see the first 2 PWM signals appear on outputs 3 & 4, because that pass through example routes the stereo audio from one shield's inputs to the others outputs and vise versa.

This is the exact code I ran on the Teensy 4.1 for this test:

Code:
#include <Audio.h>

AudioInputI2SQuad        i2s_quad1;      //xy=150,69
AudioOutputI2SQuad       i2s_quad2;      //xy=365,94
AudioConnection          patchCord1(i2s_quad1, 0, i2s_quad2, 2);
AudioConnection          patchCord2(i2s_quad1, 1, i2s_quad2, 3);
AudioConnection          patchCord3(i2s_quad1, 2, i2s_quad2, 0);
AudioConnection          patchCord4(i2s_quad1, 3, i2s_quad2, 1);
AudioControlSGTL5000     sgtl5000_1;     //xy=302,184
AudioControlSGTL5000     sgtl5000_2;     //xy=302,254

void setup() {
  // create 4 test waveforms and distinct frequencies
  analogWriteFrequency(28, 440);
  analogWriteFrequency(33, 530);
  analogWriteFrequency(36, 610);
  analogWriteFrequency(37, 610);
  analogWrite(28, 128);
  analogWrite(33, 128);
  analogWrite(36, 64);
  analogWrite(37, 190);

  AudioMemory(12);

  // Enable the first audio shield, select input, and enable output
  sgtl5000_1.setAddress(LOW);
  sgtl5000_1.enable();
  sgtl5000_1.inputSelect(AUDIO_INPUT_LINEIN);
  sgtl5000_1.volume(0.5);

  // Enable the second audio shield, select input, and enable output
  sgtl5000_2.setAddress(HIGH);
  sgtl5000_2.enable();
  sgtl5000_2.inputSelect(AUDIO_INPUT_LINEIN);
  sgtl5000_2.volume(0.5);
}

void loop() {
}
 
Here's a closer look at the PWM output to audio shield input connection.

DSC_0871_web.jpg

The whole thing is mounted on a test board that just routes all 48 pins of the Teensy 4.1 to 3 sockets. I plugged the 2 audio shields into the 2 sockets. The first shield is just a regular rev D shield with no modifications.

The 2nd shield has its I2C address jumper changed, and the 2 data pins are cut and routed to pin 6 and 32. Here's come close up photos so you can see exactly what I tested.

DSC_0874_web.jpg

DSC_0876_web.jpg
 
Thanks, everyone for the suggestions and the photos. With this help, I got it to work!

I disconnected my wiring for Pin6 and made my wiring look more like Paul's. Digital values were clearly banging away on the scope. And, audio passed through the system successfully. Great.

Then, I removed the new wiring and re-attached my original wiring. And it still worked.

That's so frustrating. I mean, I love the fact that it now works. I hate the fact that I don't know why my first and second attempts didn't work. But, desoldering the end of one wire and resoldering it 5 minutes later appeared to do it. Once again, blame the amateur with the soldering iron.

Thanks again for all your help. It was very helpeful to me to get confirmation through your posts and through your pictures that Quad does work with T4 and that the problem must have been with me.

Chip
 
Well, glad to hear that it now works as expected!
Yeah, I recognize the frustration...

Paul
 
I am looking to do this on a T4.0.

Do I still jump to pin32 (pad)?
Do I need to remove the 10K resistor?

Almost positive the first question is a yes, but not sure about the second.
 
Do I still jump to pin32 (pad)? Yes.
Do I need to remove the 10K resistor? Probably not. Mind you, since you have the audioadapters stacked on top of eachother, and thus connected the pins 6 in parallel, the resulting pullup value is 5K. This value is probaby not a problem but it does not hurt to remove the 10K resistor from both boards since you won't be using pin 6 as a CS line.

Paul
 
Back
Top