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

Thread: Teensy 4.0 I2S Support

  1. #1
    Senior Member Blackaddr's Avatar
    Join Date
    Mar 2017
    Location
    Canada
    Posts
    247

    Teensy 4.0 I2S Support

    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?

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

  3. #3
    Senior Member Blackaddr's Avatar
    Join Date
    Mar 2017
    Location
    Canada
    Posts
    247
    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?

  4. #4
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,768
    Quote Originally Posted by Blackaddr View Post
    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.

  5. #5
    I'm excited to get my new T4, but how do I tell which rev my audio shield is?

  6. #6
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    3,359
    Quote Originally Posted by ofishal View Post
    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):

  7. #7
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,768
    Rev D is coming soon. Here's the first prototype, on my desk right now...

    Click image for larger version. 

Name:	DSC_0576_web.jpg 
Views:	86 
Size:	165.4 KB 
ID:	17203

    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.

  8. #8
    Member
    Join Date
    Jun 2016
    Location
    rural West Virginia
    Posts
    61
    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.

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

    Click image for larger version. 

Name:	Teensy4-AudioBoard.jpg 
Views:	226 
Size:	149.4 KB 
ID:	17212

    Below is a picture of it actually wired.

    Click image for larger version. 

Name:	IMG_20190814_110100055.jpg 
Views:	69 
Size:	285.9 KB 
ID:	17213

    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

  10. #10
    Senior Member
    Join Date
    Feb 2015
    Posts
    102
    Paul just committed a fix for that a few hours ago, you will probably need to pull the absolutely latest to get it.

    https://github.com/PaulStoffregen/Au...fd086b37474443

  11. #11
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,768
    Install 1.47 (not beta). It has the simultaneous I2S fix.

    https://www.pjrc.com/teensy/td_download.html

  12. #12
    Senior Member
    Join Date
    Oct 2015
    Location
    Vermont, USA
    Posts
    195
    Quote Originally Posted by wcalvert View Post
    Paul just committed a fix for that a few hours ago, you will probably need to pull the absolutely latest to get it.

    https://github.com/PaulStoffregen/Au...fd086b37474443
    It works! Yay!

    Thanks so much,

    Chip

  13. #13
    Junior Member
    Join Date
    Aug 2019
    Posts
    9
    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?

  14. #14
    Senior Member DD4WH's Avatar
    Join Date
    Oct 2015
    Location
    Central Europe
    Posts
    505
    Quote Originally Posted by reaganr View Post
    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

  15. #15
    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.

    Click image for larger version. 

Name:	Teensy_SPDIF_Schematic_01.png 
Views:	68 
Size:	20.9 KB 
ID:	17234

    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?

  16. #16
    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.
    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. :-)

  17. #17
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,768
    Quote Originally Posted by JayShoe View Post
    It's not as easy as this, is it?
    There is the small matter of (so far) no software support for Teensy 4.0's S/PDIF peripheral in the audio library.

  18. #18
    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.

  19. #19
    Senior Member DD4WH's Avatar
    Join Date
    Oct 2015
    Location
    Central Europe
    Posts
    505
    Quote Originally Posted by JayShoe View Post
    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 . . .

  20. #20
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    3,359
    Quote Originally Posted by PaulStoffregen View Post
    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.

  21. #21
    Senior Member DD4WH's Avatar
    Join Date
    Oct 2015
    Location
    Central Europe
    Posts
    505
    Quote Originally Posted by JayShoe View Post
    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 by DD4WH; 08-15-2019 at 04:19 PM.

  22. #22
    Junior Member
    Join Date
    Aug 2019
    Posts
    9
    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!

  23. #23
    Junior Member
    Join Date
    Aug 2019
    Posts
    9
    looks like you got it. i was having issues until I grounded SCL. havent figured out how to control volume though

  24. #24
    Quote Originally Posted by reaganr View Post
    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.

  25. #25
    Senior Member DD4WH's Avatar
    Join Date
    Oct 2015
    Location
    Central Europe
    Posts
    505
    Quote Originally Posted by JayShoe View Post
    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.

Posting Permissions

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