Forum Rule: Always post complete source code & details to reproduce any issue!
Page 1 of 2 1 2 LastLast
Results 1 to 25 of 29

Thread: Teensy 4.1 and 4-channel audio (AudioInputI2SQuad)

  1. #1
    Senior Member
    Join Date
    Oct 2015
    Location
    Vermont, USA
    Posts
    256

    Teensy 4.1 and 4-channel audio (AudioInputI2SQuad)

    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 by chipaudette; 05-28-2020 at 08:30 PM.

  2. #2
    Senior Member
    Join Date
    Oct 2015
    Location
    Vermont, USA
    Posts
    256
    For those more visually-inclined, here are the mods described in another form:

    Attachment 20336

    Attachment 20337

  3. #3
    Senior Member PaulS's Avatar
    Join Date
    Apr 2015
    Location
    Netherlands
    Posts
    277
    Hi Chip, when I click on the attachments I get this error:

    Click image for larger version. 

Name:	popup.PNG 
Views:	9 
Size:	4.0 KB 
ID:	20350

    Using Chrome on Windows 10.

    Regards,
    Paul

  4. #4
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    12,228
    Quote Originally Posted by PaulS View Post
    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

  5. #5
    Senior Member
    Join Date
    Oct 2015
    Location
    Vermont, USA
    Posts
    256
    Second attempt at attaching pics...

    Click image for larger version. 

Name:	Step1.jpg 
Views:	29 
Size:	147.3 KB 
ID:	20351

    Click image for larger version. 

Name:	Step2.jpg 
Views:	24 
Size:	146.7 KB 
ID:	20352

  6. #6
    Senior Member PaulS's Avatar
    Join Date
    Apr 2015
    Location
    Netherlands
    Posts
    277
    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?
    Click image for larger version. 

Name:	Capture.PNG 
Views:	11 
Size:	456.7 KB 
ID:	20360

    Oops, noticed an inconsistency.
    From the Audio System Design Tool, i2s_quad1:
    Click image for larger version. 

Name:	Capture2.PNG 
Views:	6 
Size:	12.3 KB 
ID:	20358
    But the pin card shows pin 5 to be the input:
    Click image for larger version. 

Name:	Capture3.PNG 
Views:	5 
Size:	148.6 KB 
ID:	20359

    Could that be the problem?

    Regards,
    Paul

  7. #7
    Senior Member PaulS's Avatar
    Join Date
    Apr 2015
    Location
    Netherlands
    Posts
    277
    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]:

    Click image for larger version. 

Name:	Capture5.PNG 
Views:	8 
Size:	76.2 KB 
ID:	20361

    and then find the corresponding pin names in the manual:

    Click image for larger version. 

Name:	Capture4.PNG 
Views:	12 
Size:	139.4 KB 
ID:	20362

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

    Paul

  8. #8
    Senior Member vjmuzik's Avatar
    Join Date
    Apr 2017
    Posts
    601
    Quote Originally Posted by PaulS View Post
    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?
    Click image for larger version. 

Name:	Capture.PNG 
Views:	11 
Size:	456.7 KB 
ID:	20360

    Oops, noticed an inconsistency.
    From the Audio System Design Tool, i2s_quad1:
    Click image for larger version. 

Name:	Capture2.PNG 
Views:	6 
Size:	12.3 KB 
ID:	20358
    But the pin card shows pin 5 to be the input:
    Click image for larger version. 

Name:	Capture3.PNG 
Views:	5 
Size:	148.6 KB 
ID:	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.

  9. #9
    Senior Member PaulS's Avatar
    Join Date
    Apr 2015
    Location
    Netherlands
    Posts
    277
    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

  10. #10
    Senior Member vjmuzik's Avatar
    Join Date
    Apr 2017
    Posts
    601
    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.

  11. #11
    Senior Member PaulS's Avatar
    Join Date
    Apr 2015
    Location
    Netherlands
    Posts
    277
    OK. I came to my assumption when I looked at the description of the AudioInputI2SOct object:

    Name:  Capture.PNG
Views: 399
Size:  5.8 KB

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

    Paul

  12. #12
    Senior Member PaulS's Avatar
    Join Date
    Apr 2015
    Location
    Netherlands
    Posts
    277
    Hi vjmuzik, you are right, 7 is output only, 8 is input only, 6, 9 and 32 can be either or.

    Click image for larger version. 

Name:	Capture2.PNG 
Views:	10 
Size:	14.1 KB 
ID:	20368

    Paul

  13. #13
    Senior Member
    Join Date
    Oct 2015
    Location
    Vermont, USA
    Posts
    256
    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?

  14. #14
    Senior Member PaulS's Avatar
    Join Date
    Apr 2015
    Location
    Netherlands
    Posts
    277
    Quote Originally Posted by chipaudette View Post
    Have any of you ever gotten this to work yourselves with T4 or T4.1?
    Nope, don't have an audio adapter Rev D here...

    Paul

  15. #15
    Senior Member
    Join Date
    Oct 2015
    Location
    Vermont, USA
    Posts
    256
    Both boards now have their 10K resistor removed. Sadly, I'm still not able to get the 2nd audio board to acquire audio.

    Click image for larger version. 

Name:	T4 Quad.jpg 
Views:	17 
Size:	89.2 KB 
ID:	20406

    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?

  16. #16
    Senior Member PaulS's Avatar
    Join Date
    Apr 2015
    Location
    Netherlands
    Posts
    277
    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].

    Click image for larger version. 

Name:	Capture.PNG 
Views:	4 
Size:	365.1 KB 
ID:	20408

    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 https://github.com/PaulStoffregen/Au...hroughQuad.ino unmodified?

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

    Paul

  17. #17
    Senior Member vjmuzik's Avatar
    Join Date
    Apr 2017
    Posts
    601
    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.

  18. #18
    Senior Member PaulS's Avatar
    Join Date
    Apr 2015
    Location
    Netherlands
    Posts
    277
    Ah OK, I did not see that wire on my T4.1 production board, hence my question.

    Thanks,
    Paul

  19. #19
    Senior Member PaulS's Avatar
    Join Date
    Apr 2015
    Location
    Netherlands
    Posts
    277

    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:

    Click image for larger version. 

Name:	Untitled.png 
Views:	16 
Size:	16.7 KB 
ID:	20425

    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].

    Click image for larger version. 

Name:	I2Squad test.jpg 
Views:	16 
Size:	70.9 KB 
ID:	20426

    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

  20. #20
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    22,516
    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:

    Click image for larger version. 

Name:	DSC_0869_web.jpg 
Views:	19 
Size:	183.7 KB 
ID:	20430

    This is what my oscilloscope sees for the 4 outputs:

    Click image for larger version. 

Name:	file.png 
Views:	11 
Size:	51.9 KB 
ID:	20431

    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() {
    }

  21. #21
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    22,516
    Here's a closer look at the PWM output to audio shield input connection.

    Click image for larger version. 

Name:	DSC_0871_web.jpg 
Views:	16 
Size:	157.5 KB 
ID:	20432

    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.

    Click image for larger version. 

Name:	DSC_0874_web.jpg 
Views:	19 
Size:	170.5 KB 
ID:	20433

    Click image for larger version. 

Name:	DSC_0876_web.jpg 
Views:	16 
Size:	172.0 KB 
ID:	20434

  22. #22
    Senior Member
    Join Date
    Oct 2015
    Location
    Vermont, USA
    Posts
    256
    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

  23. #23
    Senior Member PaulS's Avatar
    Join Date
    Apr 2015
    Location
    Netherlands
    Posts
    277
    Well, glad to hear that it now works as expected!
    Yeah, I recognize the frustration...

    Paul

  24. #24
    Junior Member
    Join Date
    May 2020
    Posts
    14
    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.

  25. #25
    Senior Member PaulS's Avatar
    Join Date
    Apr 2015
    Location
    Netherlands
    Posts
    277
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •