Jump to content
  • 0

PMOD I2S2 with Arduino MKR Zero


jayfunk

Question

Hello, I have been working on trying to integrate the PMOD I2S2 into my MKR Zero, using the I2S interface. I was hoping you might help me to troubleshoot what I have done wrong. The overall goal is to be able to read in an audio signal to my Arduino and trigger certain events based the audio input. I am very new to working with Arduino and have gotten some basic projects done with some LED lights. I thought that the PMOD I2S2 module would be able to work with my Arduino since it has ports for the I2S protocol.

Here is how I wired the PMOD I2S2 into the Arduino MKR Zero:

ADIN MCLK  -> Purple -> D12 I2S_MCK[0]
ADIN LRCK  -> Grey   -> D3 I2S_FS[0]
ADIN SCLK  -> Black  -> D2 I2S_SCK[0]
ADIN SDOUT -> Brown  -> A6 I2S_SD0
GND        -> Blue   -> GND
VCC        -> Red    -> VCC

 

Attached is the MKR Zero Pin Out and photos of how I currently have the PMOD I2S2 wired into the Arduino. I have the PMOD Slave/Master jumper set to slave. 

 

After having gone through the wiring I pulled in the Arduino built in I2S library. From there I implemented the most basic reading example they have on the I2S repo. I am not getting any data input. I have the PMOD Line In connected by an AUX cable connected to my laptop. I am then playing some audio on the laptop. Once the Arduino boots up I do not end up getting any data from the `I2S.read()` call. I am not sure what I might be doing wrong or if it is even possible to interface the PMOD I2S2 and an Arduino. Maybe I have something misconfigured in my code or I have connected the wrong PMOD pins to the I2S inputs on the Arduino? Any help would be greatly appreciated. 

 

#include <PatternPlayback.h>
#include <I2S.h>

void setup() {
  delay(3000); // power-up safety delay

  // Open serial communications and wait for port to open:
  // A baud rate of 115200 is used instead of 9600 for a faster data rate
  // on non-native USB ports
  Serial.begin(115200);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  // start I2S at 24 kHz with 32-bits per sample
  if (!I2S.begin(I2S_PHILIPS_MODE, 8000, 32)) {
    Serial.println("I2S - Failed to initialize");
    while (1); // do nothing
  }
  Serial.println("I2S - Successfully initialized");
}

void loop() {
  int sample = I2S.read();
  if (sample) {
    Serial.println("I2S Transmission Received");
    Serial.println(sample);
  }
}


 

IMG_7680.jpeg

IMG_7682.jpeg

mkr zero pins.jpg

IMG_7683.jpg

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Hi @jayfunk

I don't have access to an MKR Zero to try to reproduce. The pin connections look pretty much correct to me, but I could also be missing something. Philips format data looks to be the correct choice. Arduino docs make it look like your sample rate will be 8 kHz. Couple ideas:

  1. You might check that your serial print output can keep up with the sample rate of the I2S controller - just storing samples in an array to print back later might be necessary.
  2. Also, if you have access to a logic analyzer of some kind, using it to look at the I2S frames could be a good idea.
  3. Check clock polarities. The transmitter (A/D) should be changing data on the falling edge of the serial clock and the receiver (MKR Zero) should be sampling on the rising edge.

The SAM D21 documentation also looks to be a useful source to check the timings involved: https://microchipdeveloper.com/32arm:samd21-i2s-overview.

Thanks,

Arthur

Link to comment
Share on other sites

  • 0

I'm biased since I work for Digilent, but the Analog Discovery 2 (you also get analog inputs) or Digital Discovery (has higher sample rates and more digital I/O) are both pretty useful for testing this kind of thing.

Thanks,

Arthur

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...