Issues with I2S in slave mode and configuring ADS127L01 with Teensy 4.1 for audio processing

Hello everyone,

I am trying to use the Audio.h library on the Teensy 4.1 with the I2S interface in slave mode to receive audio data from an ADS127L01 (an instrumentation ADC). The code works well with the ADS127L01 configured in SPI mode, but I am looking for a solution to use I2S and take advantage of the features in the Audio.h library.

Problem Description:​

  1. LRCLK and BCLK Configuration:
    • The LRCLK (or FSYNC) frequency of my ADS127L01 is 31.250 kHz. I managed to configure this correctly by adjusting the AUDIO_SAMPLE_RATE_EXACT variable to 31250.0f in the AudioStream.h file.
    • The BCLK is 1 MHz, as my ADC has only 1 channel (mono). My question is: is there any way to configure the BCLK frequency directly via the Audio.h or AudioStream.h libraries? From what I’ve seen, the Teensy automatically configures the BCLK, but it's set to 2 MHz in master mode, which is double the required frequency. I need it to be configured for 1 MHz.
  2. Objective:
    • Although the ADS127L01 works well in SPI mode, I would like to use the I2S interface to take advantage of the functionalities in the Audio.h library, such as audio processing and frequency analysis. In my case, the Teensy would be the slave and the ADS127L01 would be the master of the I2S bus.
  3. Direct Recording to SD Card:
    • I am also trying to record the data received via I2S directly to the native SD Card on the Teensy 4.1, without using an SD card connected via SPI. In the examples I’ve seen, all use an SD card configured via SPI. Is there any way to use the native SD Card on the Teensy 4.1 for this?

Pins I am using:​

ADS_PINLOCATIONTYPEDESCRIPTION
nDRDY/FSYNCAD_B1_10 / 20 - LRCLKIN/OUTData ready, active low / Frame-sync input
SCLKAD_B1_11 / 21 - BCLKIN/OUTSerial clock input
DOUTB1_00 / 8 - RXOUTSerial data input

Considerations:​

  • LRCLK is set to 31.250 kHz, as expected.
  • BCLK is set to 2 MHz, but I need it to be 1 MHz.
  • I would like to know how to configure BCLK correctly using the Audio.h library.
I would appreciate any help in advance!

Code:​


Code:
#include "Audio.h"
#include <SerialFlash.h>
#include "PCA9535.h"
#include <Wire.h>
#include "main.h"

AudioInputI2Sslave       i2sslave1;      //xy=318.23333740234375,69.23333740234375
AudioAnalyzeNoteFrequency notefreq1;      //xy=550.2333374023438,56.23332977294922
AudioConnection          patchCord1(i2sslave1, 1, notefreq1, 0);
PCA9535 expander(pca9535_addr);

void setup() {
    Serial.begin(115200);
    while (!Serial);  // Wait for serial initialization

    Wire.begin();
    InitGPIO();
    AudioMemory(50);  // Allocate memory for the audio system
    notefreq1.begin(.15);  
    Serial.println("System initialized, waiting for data...");
}

void loop() {
    // Read back fundamental frequency
    if (notefreq1.available()) {
        float note = notefreq1.read();
        float prob = notefreq1.probability();
        Serial.printf("Note: %3.2f | Probability: %.2f\n", note, prob);
    }
}
 
Hello everyone,

For test, I have configured the ADS127L01 in TDM (frame-sync) mode and I am using the Audio Library with AudioInputI2S to capture data on the Teensy 4.1. I am already receiving data, but it seems that I am only getting the 16 most significant bits, instead of the full 24-bit data that I need.

Current Data Flow:

  • The ADS127L01 sends 32 bits per sample, where only the 24 most significant bits are relevant.
  • The Audio.h library seems to capture only the 16 most significant bits or is truncating the data.
  • I need to ensure that I receive the full 24-bit data and discard only the 8 least significant bits, without losing resolution.

Questions:

  1. Does anyone know how the Audio Library processes incoming I2S data?
  2. Is it possible to modify the DMA or Audio Library settings to ensure that the correct 24 bits are stored?
  3. If I need to modify the library, which files and functions should I look into?
Any help or insights would be greatly appreciated!
 
Yes the Audio Library is 16 bit. There are other non-standard versions out there, including a floating point version, which might be of use.
 
Back
Top