How to connect I2S microphone with Audio Shield(SGTL5000) and TEENSY4.0

Lilu

Member
Hello Forum,

In the first step of using the AUDIO SHIELD circuit (rev D for TEENSY 4.0) I connected an analog microphone at the input and a pair of headphones at the output to listen the audio input signal. Using the GUI I also connected PEAK and RMS objects. I measured and displayed in the console the PEAK and RMS levels for every 500 ms. Everything worked fine. Since I understood that TEENSY 4.0 is being used in I2S MASTER mode, I checked the I2S signals between the microcontroller and SGTL5000 with an oscilloscope (I found 64 BCLK pulses for 1 period of the LRCLK signal, 3V3). I wanted to connect an I2S microphone (type MSM261S4030H0 https://www.filipeflop.com/img/files/download/Datasheet-Microfone-Sipeed-MSM261S4030H0.pdf) instead of the analog one and I interrupted the connection SGTL5000 pin 25 - Audio Shield pin 8 (immediate effect: the audio signal could not be heard by the headphones). Then I connected the I2S signals (BCLK and LRCLK generated by TEENSY MASTER) to the I2S microphone corresponding pins (SCK,WS) and the microphone SD signal to TEENSY pin 8 (instead of the CODEC signal). I expected to hear the audio signal picked up by the I2S microphone in my headphones, but nothing was heard even though I saw pulses generated on RX/Dout pin 8 line by I2S microphone. Do you know the procedure for connecting an I2S microphone to AUDIO SHIELD? Do certain conditions have to be met?
Thank you for your support


/* Adaptation of Stereo peak meter example, including RMS.
assumes Audio adapter but just uses terminal so no more parts required.

This example code is in the public domain
*/

#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>

//const int myInput = AUDIO_INPUT_LINEIN;
const int myInput = AUDIO_INPUT_MIC;

AudioInputI2S audioInput; // audio shield: mic or line-in
AudioAnalyzePeak peak_L;
AudioAnalyzePeak peak_R;
AudioAnalyzeRMS rms_L;
AudioAnalyzeRMS rms_R;
AudioOutputI2S audioOutput; // audio shield: headphones & line-out

AudioConnection c1(audioInput, 0, peak_L, 0);
AudioConnection c2(audioInput, 1, peak_R, 0);
AudioConnection c3(audioInput, 0, rms_L, 0);
AudioConnection c4(audioInput, 1, rms_R, 0);
AudioConnection c5(audioInput, 0, audioOutput, 0);
AudioConnection c6(audioInput, 1, audioOutput, 1);
AudioControlSGTL5000 audioShield;


void setup() {

AudioMemory(6);
audioShield.enable();
audioShield.inputSelect(myInput);
audioShield.volume(0.5);
Serial.begin(9600);
}


elapsedMillis fps;
uint8_t cnt=0;

void loop() {
if(fps > 500) {
if (peak_L.available() && peak_R.available() && rms_L.available() && rms_R.available()) {
fps=0;
uint8_t leftPeak = peak_L.read() * 100.0;
uint8_t rightPeak = peak_R.read() * 100.0;
uint8_t leftRMS = rms_L.read() * 100.0;
uint8_t rightRMS = rms_R.read() * 100.0;

Serial.print("LEFT PEAK = ");Serial.println(leftPeak);
Serial.print("RIGHT PEAK = ");Serial.println(rightPeak);
Serial.print("LEFT RMS = ");Serial.println(leftRMS);
Serial.print("RIGHT RMS = ");Serial.println(rightRMS);


Serial.println();
}
}
}
 

Attachments

  • Teensy_4.0 I2S.jpg
    Teensy_4.0 I2S.jpg
    71.7 KB · Views: 85
Last edited:
The I2S microphone has LSB bot 0 while the I2SInput (from audio library) uses as LSB bit 16 (uses top 16 bit)
you can hear only very loud signals
test: hit on microphone, you should hear something.
Unfortunately audio library is 16 bit, but there are 32bit or float versions around
concerning wiring, if you have all other connections made, schematic seems OK.
 
The I2S microphone has LSB bot 0 while the I2SInput (from audio library) uses as LSB bit 16 (uses top 16 bit)
you can hear only very loud signals
test: hit on microphone, you should hear something.
Unfortunately audio library is 16 bit, but there are 32bit or float versions around
concerning wiring, if you have all other connections made, schematic seems OK.

Thank you for your fast answer. In order to understand your idea, I checked in SGTL5000’s (codec used for TEENSY AUDIO rev D and driven by TEENSY 4.0 ) datasheet (https://www.nxp.com/docs/en/data-sheet/SGTL5000.pdf) the digital Audio Port formats/modes supported ( page 18) and I found: I2S Format, Left Justified Format, Right Justified Format and PCM mode. Due to the fact that I observed on oscilloscope 32 pulses of SCLK during 1 state ( High or Low ) of LRCLK, I assumes that PCM mode is not used for sure. In the meantime I found the thread ( https://forum.pjrc.com/threads/6796...h-INMP441-Microphone?highlight=i2s+microphone) where it is mentioned how to connect and I2S microphone on one of the two I2S ports.
 
Back
Top