Teensy 4.0 Quad I2s with 2x PCM5102a - Working!

Status
Not open for further replies.

alrj

Well-known member
20200520_182804.jpg

pcm5102a.jpg

I found the info in various places on the forum but not all in one place so I thought someone might find it useful like this...

Thanks to chipaudette who provided the test code and some bits of the puzzle here: https://forum.pjrc.com/threads/60532-Teensy-4-1-Beta-Test?p=238486&viewfull=1#post238486

Code:
/*
  Demo of the audio sweep function.
  The user specifies the amplitude,
  start and end frequencies (which can sweep up or down)
  and the length of time of the sweep.
   
  May 2020: Chip Audette (OpenAudio)
    * I tested this with the Teensy 4.1 and two Teensy Audio Shields
    * One shield was unmodified
    * The second shield was modified
      * Cut the trace between the two pads for the audio board's RX (Pin 7) 
      * Cut the tracce between the two pads for the audio board's TX (Pin 8)
      * Add a wire from pin 6 over to the pad that had been connected to pin 8
      * Add a wire from pin 32 to the pad that had been connected to pin 7
      * Cut the trace between the 3 pads that set the audio sheild's address (was LOW)
      * Solder-bridge the center pad to the other pad (sets the address to HIGH)

    * I based this sketch on the standard ToneSweep example
    * I extended for quad audio
    * This only tests the audio output
*/

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

AudioSynthToneSweep     myEffect1,myEffect2;
AudioOutputI2SQuad      audioOutput;        // audio shield: headphones & line-out

// The tone sweep goes to left and right channels
AudioConnection         c1(myEffect1, 0, audioOutput, 0);
AudioConnection         c2(myEffect1, 0, audioOutput, 1);
AudioConnection         c3(myEffect2, 0, audioOutput, 2);
AudioConnection         c4(myEffect2, 0, audioOutput, 3);

AudioControlSGTL5000 audioShield1;
AudioControlSGTL5000 audioShield2;


float t_ampx = 0.8;
int t_lox = 10;
int t_hix = 22000;
// Length of time for the sweep in seconds
float t_timex = 5;
// <<<<<<<<<<<<<<>>>>>>>>>>>>>>>>
void setup(void)
{
  
  Serial.begin(9600);
  while (!Serial) ;
  delay(3000);

  AudioMemory(10);

  audioShield1.setAddress(LOW);
  audioShield1.enable();
  audioShield1.volume(0.5);
  
  audioShield2.setAddress(HIGH);
  audioShield2.enable();
  audioShield2.volume(0.5);

  Serial.println("setup done");

  //play upward tone sweep through first audio shield
  Serial.println("Playing tone sweep from FIRST audio shield.");
  if(!myEffect1.play(t_ampx,t_lox,t_hix,t_timex)) {
    Serial.println("AudioSynthToneSweep 1 - begin failed");
    while(1);
  }  
  while(myEffect1.isPlaying());    // wait for the sweep to end

  //play upward tone sweep through the second audio shield
  Serial.println("Playing tone sweep from SECOND audio shield.");
  if(!myEffect2.play(t_ampx,t_lox,t_hix,t_timex)) {
    Serial.println("AudioSynthToneSweep 2 - begin failed");
    while(1);
  }  
  while(myEffect2.isPlaying());    // wait for the sweep to end

  Serial.println("Done");
}

void loop(void)
{
}

The AudioControlSGTL5000 instances are not needed in the code above but it still works with them in there.

The wires must be really short! even running wires to one DAC next to the other is too long and will cause issues on the second card. my swift solution was to cut the DIN pin shorter on the top board (this is the only pin that is not shared) and then stack them on top of each other.

This only started being supported from Teensyduino Version 1.52. previous versions.. the quad I2S output doesn't work on T4

Pinouts...
VCC -- 5v
3.3v -- I didn't connect this, probably a 3.3v out, see post below.
GND -- Ground
FLT -- Ground
DMP -- Ground
SCL -- No Connections (leaving floating)
BCK -- Pin 21
DIN -- Pin 7 for the first PCM5102a then Pin 32 for the second (this is one of the little tabs on the back on the T4.0, it has a bigger pad on the T4.1
LCK -- Pin 20
FMT -- Ground
XMT -- Ground

Hopefully at this point - music! or at least a sine sweep.
 
Last edited:
Pinouts...
VCC -- 5v
3.3v -- didn't connect this, maybe it better if you do? time will tell.
GND -- Ground
I suspect the 3.3v is the output of the 3.3v voltage regulator on the pcb. I.e. the PCM5102a runs at either 1.8v or 3.3v (max of 3.9v). So the pcb adds a voltage regulator to reduce the 5v down to 3.3v. They presumably added a pin in case you needed 3.3v. I've seen several devices have a similar pin. Since the Teensy has its own voltage regulator, you don't need to use the pin.
 
Status
Not open for further replies.
Back
Top