Rev C cards with a Teensy 4.1

craigyb

Member
So I want to create 6 to 8 individual 16 bit audio outputs from a Teensy 4.1, my idea is to create a 6 voice oscillator board similar to the TSynth but with the dual VCO section only created with the Teensy.

Problem is that I only have 4x Rev C cards left over from other projects and as I will not be fitting the cards directly onto the Teensy 4.1, can I simply connect 3 or 4 cards onto a board with the Teensy and hard work them to it. The cards look identical in the schematics with just different pin outs.

Would this work as I'm in the Ukraine and rev D cards are impossible to purchase?
 
Yes - as you mentioned it is simply the pinouts changed. You just need to be careful when you wire it up. One of Paul's T4 Beta test boards had socket on it for the Rev C (this was before there was a Rev D)
 
Thanks Kurt, I think I saw something posted by Paul showing a demo of multiple outputs for at least 2 cards. I will build a little test board with sockets for everything so I can mod and change as I need.
 
should work with custom software:
T4.x has up to 4 I2S data out ports, which could generate 16 out channels
for 4 Audioboards you would need to use two different I2C controls ports.
 
Yes, Rev C audio boards work fine with Teensy 4.1 if you use reasonably short wires to route the signals the correct pins. MCLK and GND are the wires where length matters. But don't overthink the "reasonably short", as an extra inch or few centimeters doesn't make much difference.

Rev B and older can also work, if you add a resistor in to the MCLK signal. Rev C has the resistor built in.
 
should work with custom software:
T4.x has up to 4 I2S data out ports, which could generate 16 out channels
for 4 Audioboards you would need to use two different I2C controls ports.
I think there's something slightly screwy with your maths here - each I²S out gives two channels, so you can have 4x2 on I2S1 and another 1x2 on I2S2 for an easy-ish maximum of 10 output channels.

For the "custom software" <blows own trumpet> you could look at this modification which is intended to simplify using other I²C control ports and addresses on SGTL5000-based boards. They can only use 2 different control addresses, so you'll have to modify 1 board to the other address to control 6 outputs, or 2 boards to control the full 8 outputs, using 2 different I²C ports (Wire and Wire1). Alternatively, without modifying your audio adaptors, you could control one each on Wire, Wire1 and Wire2 for a total of 6 outputs.
 
Thanks for the information, having a hard time with Putin and his missiles at the moment, but I will try and knock up a board tomorrow.
 
I think there's something slightly screwy with your maths here - each I²S out gives two channels, so you can have 4x2 on I2S1 and another 1x2 on I2S2 for an easy-ish maximum of 10 output channels.
I guess you are right on the number. For the rest, that was my idea also.
 
I've got 3 boards wired up on each I2c output using the modified audio library that can address wire, wire1 etc and although everything compiled when I'm using the test code created by Paul recently no waveforms are generated. I guess I should just try and get sound out of one card first.
 
Hi Paul

Yes, that's the code I'm using with changes to the setaddress line to setwire, but even without the changes I would have expected card 1 to work.

Also I tried an I2c scanner sketch and it couldn't find any cards which I thought was a bit strange. I will make a schematic and post it up shortly.
 
Schematic_revc_2022-07-12.png

I hope this is viewable, although I have 3 cards attached, I've only shown 3
 
Code:
#include <Audio.h>


// GUItool: begin automatically generated code
AudioInputI2SHex         i2s_hex2;       //xy=190,343
AudioOutputI2SHex        i2s_hex1;       //xy=431,344
AudioConnection          patchCord1(i2s_hex2, 0, i2s_hex1, 0);
AudioConnection          patchCord2(i2s_hex2, 1, i2s_hex1, 1);
AudioConnection          patchCord3(i2s_hex2, 2, i2s_hex1, 2);
AudioConnection          patchCord4(i2s_hex2, 3, i2s_hex1, 3);
AudioConnection          patchCord5(i2s_hex2, 4, i2s_hex1, 4);
AudioConnection          patchCord6(i2s_hex2, 5, i2s_hex1, 5);
AudioControlSGTL5000     sgtl5000_1;     //xy=633,280
AudioControlSGTL5000     sgtl5000_2;     //xy=633,368
AudioControlSGTL5000     sgtl5000_3;     //xy=635,457
// GUItool: end automatically generated code

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.setWire(Wire, 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.setWire(Wire1, LOW);
  sgtl5000_2.enable();
  sgtl5000_2.inputSelect(AUDIO_INPUT_LINEIN);
  sgtl5000_2.volume(0.5);
}

void loop() {
}
 
Also I tried an I2c scanner sketch and it couldn't find any cards which I thought was a bit strange.

SGTL5000 chips will not respond to I2C unless you have MCLK active.

For testing, you can add analogWriteFrequency() and analogWrite() in the scanner example setup() function, to cause a waveform on pin 23. Just a couple MHz is plenty. The exact frequency doesn't matter and you don't need BCLK or LRCLK if you're only trying to use I2C. Or add the audio library and 1 instance of any I2S object to cause MCLK, BCLK, LRCLK to turn on. Even if you don't have an oscilloscope or frequency counter, just a quick DC voltmeter check on pin 23 can confirm if a clock is present. The duty cycle is 50% so you should measure about 1.65 volts if MCLK has a clock signal present.
 
I can see a clock on the MCLK line, more of a sinewave but symmetrical in appearance.

I have loaded another test sketch which plays a sinewave with alternating frequencies and this works on sound card 1, so I'm confident in my wiring.

20220712_204906.jpg

20220712_204923.jpg
 
Last edited:
I can't 100% see your wiring, but it looks as if you only have one I²S input wired; if I'm reading the library code right, your second audio adaptor needs its DOUT / pin 13 wired to the T4.1 pin 6, which can function as either OUT1D or (presumably) IN1B.

Secondly, I2S1 has 5 data pins, each supporting 2-channel audio, but you have to have at least one configured as output and one as input. Hence you can't use an AudioInputI2SHex and an AudioOutputI2SHex together - one has to be Quad. They'll clash (I think) over the use of T4.1 pin 9, and probably do neither function! The audio system design tool puts a warning triangle on the two I2SHex objects when I import your design from post #17, for that very reason...
 
Last edited:
Spent a few minutes looking over the wiring. MCLK, BCLK, LRCLK looks good. I2C looks probably ok too. Looks like the DIN connections are good too, going to pin 7 (OUT1A), pin 32 (OUT1B) and pin 8 (OUT1C).
 
Hence you can't use an AudioInputI2SHex and an AudioOutputI2SHex together - one has to be Quad.

Yes, I believe that is probably the cause of the problem.

I imported the audio instances from msg #17 back in the design tool, and sure enough it shows the warning that they can't work together.

screenshot.png
 
Back
Top