How to read an I2S 24bit signal?

Status
Not open for further replies.

nicopuw

New member
Hello everyone,
Im new to the forum and wanted to ask for some help on a current project Iam working on.

The project:
Recently I finished a circuit board which has a CS5381 to input signals from a micpreamp.
The ADC transmits an 24bit I2S signal as master at variable sample rates (44.1kHz, 48kHz, 88.2kHz, 96kHz). An S/PDIF converter (CS8406) recieves the I2S signal as slave device. For controlling the sample rates, copyright and other stuff Iam using a Teensy4.0 as well as a Touchdisplay as human interface and visualization.

And here lies the problem...
My goal is to recieve the I2S signal with the teensy and perform a fft on it. Everything works fine except for the i2s part. Does anyone have an example to to implement and read I2S with a bit depth of 24? I guess that I just dont know where to start. Iwas looking through the forum threads but couldn't find any helpful information on that regard (maybe cause Im pretty lost when it comes to more advanced programming).
Im thankful for any information pointing me in the right direction :)
Maybe someone did something similar.

Sorry for my english. .. Im more used to read then to write english:)

Cheers

Nico
 
Not a complete answer, but perhaps a start:

In this post: https://forum.pjrc.com/threads/6859...o-I2S-ports-on-Teensy-4-0?p=293023#post293023 I have shared some code that sets up the DMA engine to receive two streams of 32-bit I2S stereo samples on a Teensy 4. There are some registers in the DMA engine that need to be correctly set to handle 32 (or 24) bits rather than 16 for each sample. If it is set up incorrectly, the DMA engine is likely to run amok through all of memory, so it pays off to read the relevant pages of the (huge) datasheet. The comments in my code may help a little. You seem to have only one I2S channel, so my code for the quad (dual stereo) input is not exactly what you want, but hopefully a good start. If you set up the codec for the correct bit alignment it might not matter whether you treat the samples as 24 or 32 bits long on the Teensy side.

Also my code is making use of Chip Audettes AudioStream_F32 version of the Audio library where floats are used instead of int16. You probably also want to do this since you seem to care about using 24 instead of 16 bits.

If it is not really that important to make use of all the 24 bits from the codec, the by far easiest would be to set up the codec for 16 bits and use the standard Audio functions of the Teensy.

If you want to use other sample rates than 44.1 kHz, you probably will have to do a lot more coding. Or find some existing solution that I am not aware of.

Per
 
Hi Per,

thanks for your reply. Actually Iam fine with just just 16BIt, since its just for visualization :)
I will try to work with the library. But since Iam using the Teensy as slave device, wouldn't it not set the sample rate based on the master?
 
If the top 16 bits will do, try the easy thing first and use the audio library. It has I2S slave mode input, where the external LRCLK controls the audio sample rate.

If you're not familiar with the audio library, this tutorial covers all the basics.

https://www.pjrc.com/store/audio_tutorial_kit.html

The tutorial uses only I2S master mode, but hopefully once you read part 2 and become familiar with use of the design tool, you'll see the many other input & output options and their documentation.
 
I've played a little with the library already and I'm pretty motivated right now. I guess I´ll give the tutorial a try I'll. Thanks a bunch.
 
Status
Not open for further replies.
Back
Top