Teensy 4.0 I2S Support

Status
Not open for further replies.

Blackaddr

Well-known member
I understand that the T4 is not direct pin compatible with the audio shield as the I2S pins are in different locations. Looking through the massive Beta thread, there was some discussion about an adaptor board not being possible either because the SAI1/SAI2 pins are both split between the regular pins and back side but I may be interpreting that wrong.

For SAI1... MCLK, BCLK and LRCLK (23, 21, 20) are all on the regular pins but I'm a little confused about the relationships between the IN/OUT pins. For example, can we use pins 8 and 7 (IN1 and OUT1A respectively) to complete the data in and out for the I2S interface?
 
I updated the audio shield page recently, with this:

Update: Teensy 4.0 has its digital audio signals (MCLK, BCLK, LRCLK, TX, RX) in different locations. On Teensy 3.x, these are pins 11, 9, 23, 22, 13. On Teensy 4.0, those signals are pins 23, 21, 20, 7, 8. This audio shield will only work if wires are used to route those 5 signals. It does not work if soldered directly above or below a Teensy 4.0. The MCLK signal also requires a 100 ohm resistor in series. We added this resistor in "Rev C", which is currently shipping, but not yet documented on this page. If you have an older "Rev B" audio shield, you will need to use a 100 ohm resistor in line with MCLK to use it with Teensy 4.0. We are working on a "Rev D" audio shield with the 5 signals routed for Teensy 4.0, for release in early September.

When I get some time, will add a photo of the required wiring. A photo should be a lot more visible than just this text.
 
Thanks Paul. Very much looking forward to using the Teensy 4.0 with my TGA Pro and this info will help me make an adaptor board. I presume the 100 ohm resistor on MCLK was to help absorb some reflections from the processor's fast edges?
 
I presume the 100 ohm resistor on MCLK was to help absorb some reflections from the processor's fast edges?

Yup, pretty much. It came up during the beta test and was discussed somewhere in the 4000+ message beta test thread.

Fortunately it was discovered long enough ago that we were able to make a revision to add the resistor on the audio shield by the time of Teensy 4.0's release.

Another rev is coming soon which will have the pins re-routed so it works directly on top of Teensy 4.0.
 
I'm excited to get my new T4, but how do I tell which rev my audio shield is?

There have been 4 audio shields released so far (not counting the new audio shield specifically for the T4):
  • The real original audio shield had a black PCB (I was reminded of this when I looked in the drawer with my old audio shields);
  • Then there was a re-release of the audio shield with a green PCB, but same functionality (as I recall there were electrical issues with the black PCB's so Paul changed to green);
  • In January 2015, revision B of the board was released that has some minor changes -- it has a green PCB, and it says REV B on the silkscreen underneath the board (see https://www.pjrc.com/store/teensy3_audio.html for the details of the changes, but note the picture on that page is still the first revision board);
  • Just recently there was a revision C of the board that has the MCLK resistor added. It has a green PCB and it says REV C on the silkscreen underneath the board. Sparkfun is now carrying this board. I don't know of the other distributors (Adafruit, Digi-key, etc.). Presumably in a few days Paul will get some breathing room to update the page.

Paul has provided the specifications for the shield that was used during the beta test to rewire the audio board. You can order the PCB from oshpark if desired, though given its size, it is somewhat pricey ($37.10 for 3 boards for USA delivery):
 
Rev D is coming soon. Here's the first prototype, on my desk right now...

DSC_0576_web.jpg

On the very first ones (Rev A), the green and black ones were identical, other than the color.

The black solder mask never caused any trouble on the audio shield, but it did cause some of the original Teensy 3.0 boards to fail (during testing). We dropped the black color for all boards, even though it was good enough for some. The green solder mask is a much higher quality.
 
A photo should be a lot more visible than just this text.

I'm not sure how much it helps but pictures of my test board are in post #115 of the Teensy 4.0 release thread. My board has sockets for the T4.0 and a T3.2 or T3.6. It is also dual footprint for the Teensy audio shield or Paul's CS42448 board. All 6 combinations work even though I forgot the 100 ohm resistor on MCLK and have rev B audio adapters. I will probably add a 51 ohm SMD part at each end of the wire.

The three clock lines are run as twisted pair with the grey wire being ground as they are almost 4 inches long. The other signals are just flying wires. Each wire has different color tracers to make it easier to fix or change once the wiring reaches the ratsnest / furball stage.

The picture was taken with only the minimum wiring needed for audio functionality. I will be adding all the synthesizer functionality as time goes on. The SPI lines for the SD card socket are not implemented yet, as I don't need SD functionality at this time.

Beta 6 or later TD code is needed to get the fixed I2S output file.
 
Can anyone confirm that AudioInputI2S works with the Teensy 4.0?

It does not work for me. I can play sounds out via AudioOutputI2S but I can't bring audio in using AudioInputI2S.


My Setup:

I wired up the Teensy Audio Adapter to a Teensy 4.0 using the pin remapping described by Paul (https://www.pjrc.com/store/teensy3_audio.html). Below is a picture of my wiring diagram that I made for myself.

Teensy4-AudioBoard.jpg

Below is a picture of it actually wired.

IMG_20190814_110100055.jpg

Software:

I'm running Arduino 1.8.9 with Teensyduino 1.4-beta7. I'm running the ToneSweep and the PassThroughStereo examples from the Teensy Audio library.

Symptoms:

ToneSweep runs fun. PassThrougStereo, however, produces no audio at the output (yes, I am injecting audio into the system). Most curiously, going back to ToneSweep, if I simply add a line instantiating an AudioInputI2S object, it breaks ToneSweep:

Code:
AudioInputI2S      audioInput;  //I added this
AudioSynthToneSweep myEffect;   //this was here
AudioOutputI2S      audioOutput;        // audio shield: headphones & line-out

// The tone sweep goes to left and right channels
AudioConnection c1(myEffect, 0, audioOutput, 0);
AudioConnection c2(myEffect, 0, audioOutput, 1);

Note that I don't need to connect audioInput to anything; simply including the line in the sketch prevents the ToneSweep sketch from making any audio. It compiles fine. It simply doesn't output any audio.

Has anyone confirmed that AudioInputI2S works with Teensy4?

Chip
 
zelda and guitar sketches sounding great via my PCM5102 module! listing some DAC schematics/options would make folks happy when they realize t4 has no audio pins or usb midi yet & doesnt work with their audio shields. :) has anyone tried SPDIF?
 
zelda and guitar sketches sounding great via my PCM5102 module!

Could you post your sketch for using the PCM5102 with the Teensy 4.0? Or did you just use an example sketch? If yes, would be nice to know which one you used.

Thanks a lot!

Regards, Frank DD4WH
 
has anyone tried SPDIF?

I'm working on an Audio Breakout board and it will have TOSLINK SPDIF. Let me document my findings.

- There is an Optical Audio Output Board for Teensy 3.1 at OshPark.
- There is a discussion about using WM8804 on the Teensy Forum. But we don't need this chip on the T4, because it's integrated into it.
- The new Teensy has pins for inputs and outputs of SPDIF. 14 = S/PDIF OUT and 15 = S/PDIF IN.

The part from the Oshpark board is an Everlight Electronics Co Ltd PLT133/T6A TRANSMITTER FBR OPT IR PHOTOLINK. One possible match for the receiver is a Everlight Electronics Co Ltd EAPLRAA4 RECEIVER MODULE.

It's not as easy as this, is it? I have power supply coming from the Teensy with a ferrite bead and some Capacitors, and then a direct connection from the transmitter and receiver. The ferrite bead was in another schematic I was studying, so I left it there.

Teensy_SPDIF_Schematic_01.png

I would also like to document what is required of the coaxial SPDIF output for those who prefer coaxial over optical. In the above referenced OshPark share Paul says, "Resistors and a small transformer can also be used, for non-optical RCA connector S/PDIF." I would like to also draw this schematic at some point... There are some examples online but I'll wait for feedback on the optical schematic first.

So how does my schematic appear? Will it work?
 
There is the small matter of (so far) no software support for Teensy 4.0's S/PDIF peripheral in the audio library.

OK, I'll still incorporate it into my breakout board. Then when there is time or interest, it will make testing easier. Does the schematic look right? Thanks Paul. I'm excited to work with this new board.
 
In case you missed it, I documented the connections in a previous post. It seems to have resonated with many people because I hear about this chip being used with the Teensy a lot. :)

Thanks for that hint! Is working now. Just for documentation for others to try:

Teensy 4.0 and DAC PCM5102 module from AliExpress

Vcc = Vin
GND = GND
FLT = GND
SCL = floating
BCK = BCK = pin 21
DIN = TX = pin 7
LCK = LCRLK = pin 20
DMP = GND
FMT = GND
XMT = 3V3

Audio lib Examples that I have tested and work:
Sample Player, Guitar, Zelda,

Will now try to connect ADC PCM1808 board additionally . . .
 
Rev D is coming soon. Here's the first prototype, on my desk right now...
Given the different pinouts between 3.x and 4.0 for I2S, assuming the rev D board is only for Teensy 4.x, it may be helpful to those of us that serially buy boards over time, and toss them back into a bin for later reuse to add to the silk screen on the bottom saying Teensy 4.0, in addition to "Rev D". Though if the Rev D board has solder jumpers that I could easily convert it between a Teensy 3.x and Teensy 4.0 that would be even better.

BTW I was going through my bin of audio boards when I saw the board with the black PCB which reminded me of the original color.

Now that we know there is a new audio board coming for the T4, I wonder what we can do about the prop shield? I found the prop shield to be the perfect companion for the T3.2 (and 3.5/3.6 with adjustments). In fact I stopped using the audio board when the prop shield came out. While the sound isn't the best, for props, it is good enough. I'm wondering if it would make sense something small that would use I2S instead of the DAC for mono sound. With the prop shield, the key is that it doesn't increase the size of the Teensy that much while the sound board makes much wider (and it can't fit in the hilt of a lightsaber).

I realize Paul, you can't share details of unannounced products until they are close to fruition, and you may be already designing one. Or perhaps the sales of the prop shield aren't high enough to warrant a T4 version.
 
In case you missed it, I documented the connections in a previous post. It seems to have resonated with many people because I hear about this chip being used with the Teensy a lot. :)

Thanks again for the hints! ADC works together with DAC !

Connections for documentation:

Teensy 4.0 with ADC PCM1808 module (line-in Input), running simultaneously with the DAC PCM5102 (headphone output):
ADC PCM1808 connections to Teensy 4.0:
FMT = GND
MD1 = GND
MD0 = GND
GND = GND
+5V = Vin
3V3 = 3V3 --> the PCM1808 needs BOTH, +5Volts AND 3V3 connected
BCK = pin 21
OUT = RX = pin 8
LRC = LRCLK = pin 20
SCK = MCL = pin 23

DAC PCM5102 connected as in post #19

Running examples:
PassThroughStereo, FilterFIR --> a 100 tap FIR Filter uses 2.5% of the processor load of the Teensy 4.0 @44.1ksps sample rate, thats incredible !

All the best,

Frank DD4WH
 
Last edited:
that's a great thread- and info on spdif too. coax would be great too as there are audio interfaces floating around with that (i.e. vrm box) thanks!
 
looks like you got it. i was having issues until I grounded SCL. havent figured out how to control volume though
 
i havent figured out how to control volume though

The PCM5102A doesn't have software control, it's a hardware DAC. You'll have a digital volume, processed by the Teensy. Place it inline of the audio project on the audio design tool. Then you can read your PC's volume and apply it to the volume in the project. This will adjust the I2S stream up or down, digitally. From the datasheet you'll need "software mode, available only in the PCM512x, PCM514x, and PCM5242 devices". I'm working on a module for the PCM5242, it has a volume control that we'll have to control via I2C.

i was having issues until I grounded SCL

Do you mean the Master System Clock? Did you try to connect it to the Teensy 4 Master Clock 23_A9_CRX1_MCLK1? If it's not working with the Master Clock from the Teensy then you are running on the PLL Mode where it runs without the System Clock. Worth noting.
 
Do you mean the Master System Clock? Did you try to connect it to the Teensy 4 Master Clock 23_A9_CRX1_MCLK1? If it's not working with the Master Clock from the Teensy then you are running on the PLL Mode where it runs without the System Clock. Worth noting.

Oh, did not know that. I left SCL of the DAC unconnected.

When testing with the Convolution object by DerekR I experienced strange crackling noises. Could it be that this is caused by this?

I will try to connect SCL of the DAC to pin23 of the Teensy 4.0.
 
Status
Not open for further replies.
Back
Top