Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 16 of 16

Thread: Teensy in Raspberry I2S based digital chain.

  1. #1
    Junior Member
    Join Date
    Sep 2018
    Posts
    8

    Teensy in Raspberry I2S based digital chain.

    Hello to all!
    I need some help with some I2S connection problems. I am testing some DSPs by inserting them into my (digital) audio chain.

    The starting point is:
    Raspberry PI3+ (Master) >
    Allo Isolator > (Passes Clocks according to Slave/Master direction)
    Kali Recklocker (Input Slave, Output Master) >
    TDA1543 based DAC

    I have been able to insert a Minisharc DSP (and it worked):
    Raspberry PI3+ (Master) >
    Minisharc DSP > (Input Slave, Output Master)
    Allo Isolator >
    Kali Recklocker (Input Slave, Output Master) >
    TDA1543 based DAC

    I am now trying to insert a Teensy 3.6 in place of the Minisharc:
    Raspberry PI3+ (Master) >
    Teensy 3.6 > (Input Slave, Output Slave)
    Allo Isolator >
    Kali Recklocker (Input Slave, Output Master) >
    TDA1543 based DAC

    Due to the fact that Teensy is Input and Output Slave, both the Kali Reclocker and Teensy are sharing the Clocks coming from Raspberry.
    The Teensy has been simply programmed to patch the I2S (stereo) signal through. (see picture)
    The Result is that only one specific channel is playing. Always same speaker is playing whichever channel I disable with a comment.
    The oscilloscope is the WCLK and BCLK Output from Raspberry: there are 32 bits per word cycle, so I would say BCLK is 1.4112 Mhz (44100*32).
    My understanding is that Teensy would be compatible with this I2S format ?
    Any ideas what is going on ?
    Thanks
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	20180907_192044.jpg 
Views:	6 
Size:	207.0 KB 
ID:	14682   Click image for larger version. 

Name:	20180907_190216.jpg 
Views:	3 
Size:	115.5 KB 
ID:	14683  

    Click image for larger version. 

Name:	20180907_190206.jpg 
Views:	3 
Size:	116.3 KB 
ID:	14684  
    Last edited by Bart11; 09-07-2018 at 06:57 PM.

  2. #2
    Senior Member
    Join Date
    Jul 2014
    Posts
    1,820
    Quote Originally Posted by Bart11 View Post
    The oscilloscope is the WCLK and BCLK Output from Raspberry: there are 32 bits per word cycle, so I would say BCLK is 1.4112 Mhz (44100*32).
    My understanding is that Teensy would be compatible with this I2S format ?
    Any ideas what is going on ?
    Thanks
    maybe because I2S audio library is 64 bit per word frame?

  3. #3
    Junior Member
    Join Date
    Sep 2018
    Posts
    8
    Yes, that must be the problem. Which begs the question: how do I modify the audio library?

  4. #4
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    18,153
    I2S stereo (master) does use 64 bits per frame. Long ago it was 32 bits per frame, but was changed to 64 for compatibility with the MEMS mics.

    I2S quad channel (master only) is still 32 bits per frame. Someday it too will be updated to 64, but as of verson 1.43 it's still 32.

    However, in slave mode, whatever device you connect to Teensy is in control of the clocks. Teensy has no choice but to (try to) work with whatever ratio it uses.

  5. #5
    Junior Member
    Join Date
    Sep 2018
    Posts
    8
    Hello Paul,
    ...so you are implying that (in slave mode) Teensy should be working correctly even with 32bits/frame and that the problem lies somwhere else ?
    (I am feeding the clocks from RPI)
    Thanks
    B.

  6. #6
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    18,153
    I don't know. The only testing I've done with slave mode is the WM8731 chip using this example.

    https://github.com/PaulStoffregen/Au...1MikroSine.ino

  7. #7
    Senior Member
    Join Date
    Jul 2014
    Posts
    1,820
    Quote Originally Posted by Bart11 View Post
    Hello Paul,
    ...so you are implying that (in slave mode) Teensy should be working correctly even with 32bits/frame and that the problem lies somwhere else ?
    (I am feeding the clocks from RPI)
    Thanks
    B.
    maybe by changing
    Code:
    	dma.TCD->SADDR = (void *)((uint32_t)&I2S0_RDR0 + 2);
    to

    Code:
    	dma.TCD->SADDR = (void *)((uint32_t)&I2S0_RDR0);
    in the "input_i2s.cpp" file of the audio library (inside void AudioInputI2Sslave::begin(void))
    Teensy should work by taking the lower two bytes of the I2S port

  8. #8
    Junior Member
    Join Date
    Sep 2018
    Posts
    8
    Thanks for the help, I'll try it and let you know.
    (The reason I am so keen to wire up the teensy is that it can only work on 44.1khz and does not perform Asynchronous Resampling. What some percieve as a limit to me is a great advantage! My experience is that ASRC degrades sound.)

  9. #9
    Senior Member
    Join Date
    Jul 2014
    Posts
    1,820
    Quote Originally Posted by Bart11 View Post
    Thanks for the help, I'll try it and let you know.
    (The reason I am so keen to wire up the teensy is that it can only work on 44.1khz and does not perform Asynchronous Resampling. What some percieve as a limit to me is a great advantage! My experience is that ASRC degrades sound.)
    You may know, that it is (relatively) easy to modify the audio functionality to work with any sampling frequency you want by adding some functions to your sketch (i.e. without touching the audio library.

  10. #10
    Junior Member
    Join Date
    Sep 2018
    Posts
    8
    Will keep this in mind. Thanks for the tip.
    Will try the code change first and report asap.

  11. #11
    Junior Member
    Join Date
    Sep 2018
    Posts
    8
    Ps at this point I will really look into this. The I2S protocol should work even if there is a different word length between transimtter and receiver. If I am transmitting 16 bits, the receiver should be able to handle this even if it is expecting 32 bits. Maybe I wired wrongly. Will re-check everything and come back.

  12. #12
    Junior Member
    Join Date
    Sep 2018
    Posts
    8
    Quote Originally Posted by WMXZ View Post
    maybe by changing
    Code:
    	dma.TCD->SADDR = (void *)((uint32_t)&I2S0_RDR0 + 2);
    to

    Code:
    	dma.TCD->SADDR = (void *)((uint32_t)&I2S0_RDR0);
    in the "input_i2s.cpp" file of the audio library (inside void AudioInputI2Sslave::begin(void))
    Teensy should work by taking the lower two bytes of the I2S port
    Hello !
    I have repeated the experiment by placing the Teensy between Kali reclocker and the TDA1543 chip.
    I have modified the "input_i2s.cpp" as per your instructions.
    Still, only one channel is playing: the output Data line is active only when WCLK is LOW.
    There is something interesting going on though ! If I comment (disable) one of the two AudioConnectios, only half of the samples (of the Single playing channel) appear in the output.
    If I reverse the comments, data appears on the complementary half (of the playing channel). (Please note the pictures)
    I would guess this has to do with the output_i2s part of the equation. The Teensy is definitely providing Left and Right Input channel data to the Left Output channel.
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	20180909_175735.jpg 
Views:	5 
Size:	71.6 KB 
ID:	14693   Click image for larger version. 

Name:	20180909_181602.jpg 
Views:	7 
Size:	65.5 KB 
ID:	14694  

    Click image for larger version. 

Name:	20180909_181705.jpg 
Views:	6 
Size:	67.2 KB 
ID:	14695  

  13. #13
    Junior Member
    Join Date
    Sep 2018
    Posts
    8
    Quote Originally Posted by PaulStoffregen View Post
    I2S stereo (master) does use 64 bits per frame. Long ago it was 32 bits per frame, but was changed to 64 for compatibility with the MEMS mics.

    I2S quad channel (master only) is still 32 bits per frame. Someday it too will be updated to 64, but as of verson 1.43 it's still 32.

    However, in slave mode, whatever device you connect to Teensy is in control of the clocks. Teensy has no choice but to (try to) work with whatever ratio it uses.
    Hello !

    I have checked what I2S bus specifications states about different word length compatibility. In theory I2S should work whatever the word length:

    3.1 Serial Data
    Serial data is transmitted in two’s complement with the MSB first.
    The MSB is transmitted first because the transmitter and receiver
    may have different word lengths. It isn’t necessary for the transmitter
    to know how many bits the receiver can handle, nor does the
    receiver need to know how many bits are being transmitted.
    When the system word length is greater than the transmitter word
    length, the word is truncated (least significant data bits are set to ‘0’)
    for data transmission. If the receiver is sent more bits than its word
    length, the bits after the LSB are ignored. On the other hand, if the
    receiver is sent fewer bits than its word length, the missing bits are
    set to zero internally. And so, the MSB has a fixed position, whereas
    the position of the LSB depends on the word length. The transmitter
    always sends the MSB of the next word one clock period after the
    WS changes.


    https://www.sparkfun.com/datasheets/...rds/I2SBUS.pdf

  14. #14
    Junior Member
    Join Date
    Aug 2015
    Posts
    7
    Quote Originally Posted by WMXZ View Post
    You may know, that it is (relatively) easy to modify the audio functionality to work with any sampling frequency you want by adding some functions to your sketch (i.e. without touching the audio library.
    WMXZ - do you have any links or details as to how to do this (change audio lib sampling frequency), thanks

  15. #15
    Senior Member
    Join Date
    Jul 2014
    Posts
    1,820
    Quote Originally Posted by houtson View Post
    WMXZ - do you have any links or details as to how to do this (change audio lib sampling frequency), thanks
    Sorry, I was on travel,
    Have a look in https://github.com/WMXZ-EU/microSoundRecorder how to mix up basic audio-library functionality and own modification
    (OK, there is much more in it, but maybe it helps as starting point)

  16. #16
    Junior Member
    Join Date
    Aug 2015
    Posts
    7
    Quote Originally Posted by WMXZ View Post
    Sorry, I was on travel,
    Have a look in https://github.com/WMXZ-EU/microSoundRecorder how to mix up basic audio-library functionality and own modification
    (OK, there is much more in it, but maybe it helps as starting point)
    Walter - microSoundRecorder looks great - your coding ability and understanding of Teensy surpasses mine by a mile or 10 (just graduating from Arduino to VSCode).

    I very roughly follow what you are doing to change the sample rates with the PDB timer and then matching I2S.

    For my immediate needs (slowing down audio sampling for an effect) I've ended up just matching successive samples to simulate a lower sampling rate.

    I will definitely come back microSoundRecorder when I get a bit of time to look at how to do it properly - thanks for the point in the right direction.

Posting Permissions

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