Using the I2S with Teensy4.0

Status
Not open for further replies.
Teensy 4.0 does not yet support I2S slave mode, where the external chip creates the BCLK and LRCLK signals. Teensy 4.0 currently only supports I2S master mode. But that MikroE-506 board is designed for master mode. You can't connect two I2S masters together. One side must be master mode (transmitting BCLK & LRCLK) and the other must be slave mode (receiving BCLK & LRCLK).

You'll need to modify that MikroE 506 board, which involves removing the crystal and adding a resistor to connect MCLK. Details on these threads:

https://forum.pjrc.com/threads/53854?p=198733&viewfull=1#post198733

https://forum.pjrc.com/threads/55334?p=201494&viewfull=1#post201494

With those modifications and with the code shown on those threads, the MikroE-506 will listen for BCLK & LRCLK and be able to work with Teensy 4.0.
 
Last edited:
Many thanks to everyone for the quick help. Also interesting is a contribution in which a Wolfson WM8731 to 28 DIP adapter is used. This opens up the full use of all functions of the WM8731.:eek:
 
@Fritz
A few of us tried using the WM8731 with the T3.6 and found a whole lotta problems with the I2C communication. The link to the thread is I2C problems with Teensy 3.6 and WM8731 codec. Paul ultimately found the main problem was caused by ringing on the MCLK line, but it was not a complete cure and multiple retries on I2C errors was incorporated into the library. I don't know if the problem persists with the T4 - I haven't tried it.

Also be aware that there is a problem with I2S stereo input, where the left and right channels sometimes get 1 sample out of synch on program upload or power up. It may not be a problem for you but it causes havoc in quadrature signal processing where phase integrity between channels is essential. The problem seems to present in many arm processors (it's not unique to the Teensies) and many (if not all) codecs, including the WM8731.
 
the main problem was caused by ringing on the MCLK line

MCLK is only used when Teensy I2S runs in master mode. WM8731 can be used either way, but generally the MikroE 506 board is meant to run in master mode (no MCLK) with Teensy's I2S in slave mode. If used that way, this MCLK ringing isn't an issue because MCLK isn't used at all.
 
Hello forum,
there are probably several versions of MikroE-506.
The new version I'm using has Lin inputs and 11-pin header.
MikroE-506-neue Version.jpg
I used the Teensy3.6 and provided all Teensy pins with a 3.9 k pull up.
The connection to the MikroE-506 via 220R resistors.

The test program with 440Hz sine works.

greeting
Fritz
 
Hello forum.
I currently run the MikroE-506 in master mode. The digital interface MOSI and MISO are connected to each other on the MikroE-506. The digitized data is thus sent from the ADC directly to the DAC in I2S mode. So far everything seems fine.
Because of the signal quality, I would like to continue to stay in master mode with the MikroE-506.
But now there is a problem, the I2S interface of the Teensy3.6 cannot function as a slave.
Hence my idea not to use an I2S, but to operate the interface in DSP mode and send the serial data from the ADC to an input port on the Tennsy3.6.
I suspect an interrupt is not fast enough to read 6 bytes serial every 20 microseconds.
The reading function would have to be written in machine language.
Is this possible on the teensy?
greeting
Fritz
 
Is this possible on the teensy?

Yes. I2S slave mode is supported (though master mode is the normal way to use Teensy's I2S port).

In Arduino, click File > Examples > Audio > HardwareTesting > WM8731MikroSine. Connection info is in the comments on that example.

You're using Teensy 3.6, where this is fully supported by Teensyduino 1.48. But if you were using Teensy 4.0 (or anyone else with 4.0 finds this message), version 1.49-beta4 or later is needed to make this work on Teensy 4.0.

Also look for the info in the comments about the crystal frequency. If you use it with the original crystal, it will work, but audio library synthesis and other features will be shifted in frequency since the audio lib expects 44.1 kHz sample rate.
 
Thanks for the hint.
My goal is to collect measurement data at 48kHz in 24bit, so I cannot use any other sampling frequency. The measurement data are recordings with a measurement microphone that extends into the sound range below 1 Hz. The second channel is to record measurement data from an acceleration sensor.
The recorded data 24bit / 48kHz are analyzed with a math program (Scilab).

The usual recording devices, mobile recorders, end in the range of around 5-7 Hz.
The analyzes show that the frequency is high at 5-7 Hz, but are cut off by the limitation of the mobile recorder.
Therefore I want to extend these measurements in the frequency domain but stay at the sampling frequency of 48kHz.

Sincerely yours
Fritz
 
Thanks for the hint.
My goal is to collect measurement data at 48kHz in 24bit, so I cannot use any other sampling frequency. The measurement data are recordings with a measurement microphone that extends into the sound range below 1 Hz. The second channel is to record measurement data from an acceleration sensor.
The recorded data 24bit / 48kHz are analyzed with a math program (Scilab).

The usual recording devices, mobile recorders, end in the range of around 5-7 Hz.
The analyzes show that the frequency is high at 5-7 Hz, but are cut off by the limitation of the mobile recorder.
Therefore I want to extend these measurements in the frequency domain but stay at the sampling frequency of 48kHz.

Sincerely yours
Fritz

All doable, but you need to write your own I2S code.
 
My goal is to collect measurement data at 48kHz in 24bit

Have you connected an oscilloscope to watch what those lower WM8731 bits actually do, like with the inputs shorted or open circuit but no signal connected?

If you have only 2 channel scope, connect LRCLK to the external trigger input, so you can watch the data and bit clock, knowing the first MSB starts 1 clock after the trigger point.

Everyone who actually sees this with their own eyes gains a much more realistic idea of the usefulness of capturing those 8 low bits (even even the bottom couple of the top 16 bits). Some ADCs might give you 18 or even 19 good bits, but the WM8731 is about as far away from that league of performance as you can get.
 
Status
Not open for further replies.
Back
Top