PCM5242 + PCM1865 + Teensy Audio

Status
Not open for further replies.

JayShoe

Well-known member
Hello Friends,

I've been working on this project for a while, it started with other TI chips I've posted about on this forum. I'm looking for some help, if you don't mind. I have two PCM5242 EVM modules and a PCM1865 module on a (rather large) breadboard.

IMG_20190613_112147613.jpg

I have the first PCM5242 connected to USB and the on-board I2C programmer will program the chip using the TI Purepath Console. That software loads up the default parameters to make the chip play. Don't worry about the console or understanding it. What you need to know is that the Purepath Console 2 -> USB -> TAS chip -> PCM5242 to program it via I2C. Then I have the Teensy sending I2S signals to the PCM5242 via that breadboard and jumpers. When I do this, I can play USB audio through to the chip.... It works fine.

Purepath console 2 = Programming the chip (unmuting it)
Teensy = Sending I2S
WORKING...

Code:
// Code to pass through USB audio to the I2S on the teensy.... Working when the Purepath Console 2 "pre-configures" the module. 


///////////////////////////////////
// copy the Design Tool code here
///////////////////////////////////

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

// GUItool: begin automatically generated code
AudioInputUSB            usb1;           //xy=216,230.99999237060547
AudioOutputI2S           i2s1;           //xy=649,250.99999237060547
AudioConnection          patchCord1(usb1, 0, i2s1, 0);
AudioConnection          patchCord2(usb1, 1, i2s1, 1);
// GUItool: end automatically generated code


void setup() {
  Serial.begin(9600);
  AudioMemory(500);
  delay(1000);
}

void loop() {
  // do nothing


  // print a summary of the current & maximum usage
  Serial.print("CPU: ");

  Serial.print("all=");
  Serial.print(AudioProcessorUsage());
  Serial.print(",");
  Serial.print(AudioProcessorUsageMax());
  Serial.print("    ");
  Serial.print("Memory: ");
  Serial.print(AudioMemoryUsage());
  Serial.print(",");
  Serial.print(AudioMemoryUsageMax());
  Serial.print("    ");
  Serial.print("Send: (R)eset, (S)lower, (F)aster");
  Serial.println();

  // very simple timing   :-)


}

OK. So now i want to remove the Purepath Console and Program the PCM5242 with the Teensy, NOT via the Purepath Console 2 -> USB....

The second PCM5242 is connected to the teensy with both I2C and I2S (whereas the first one is just I2S on Teensy, and I2C is via the Tas/USB/Purepath programmer). This second PCM5242 is on address 0x4C, an I2C scanner I have verifies this. I need some code to write these values at startup of the application.


This was a essentially a dump from the purepath console...


Code:
cfg_reg registers[] = {

    // Unmute
    { 0x03, 0x00 }, 

    // Configure for I2S, DSP, Etc. 
    // { 0x28, 0x04 }, // I2S Configuration to "DSP" and set bits to 32 bit. 
    { 0x28, 0x02 }, // I2S Configuration to "I2S" and set bits to 32 bit.


    // { 0x03, 0x00 }, // I2S Shift to 00000100 aka 0x04
    { 0x3C, 0x01 }, // Tie left to right Volume
    { 0x3D, 0x62 }, // Left Digital Volume
    { 0x3E, 0x62 }, // Right Digital Volume
    

};

That's what I believe to be the minimum configuration via I2C to make the card play music coming in via I2S connected only to the Teensy (no purepath). Can someone please help me add some code to my existing code (above) to write those values to the registry at the start of the application? I know this is pretty straightforward code. I'm still learning and I lean on modifying existing code at this point. I figure if I can get some code to write values to the device, I can finish confirming my hardware. Once the hardware setup is confirmed with the PCM5242, I'll use the same code to then configure the PCM1865 and confirm that too with the goal of playing audio coming in from the PCM1865 through to the PCM5242.

Then I'll test it using TDM... and I should be able to get both PCM5242 and all 4 lines of the PCM1865 running on the teensy.

Any help on how to dump those registry values to the I2C lines? Thanks for the help!

Jay
 
Hello Friends,

With a little help from a freelancer I've been getting some consulting from I was able to get this working. I have tested and confirmed the PCM5242 in both I2S and TDM modes. It's pretty straight forward once I realized that the only setting you truly need to tick is the "standby mode". Once the device is out of standby mode the on-chip PLL seems to do a good job of stabilizing the signals and playing sound.

I started documenting my project at hackaday.io. Here is my recent log.
https://hackaday.io/project/166140-pcm5242-pcm1865-module/log/164800-teensy-pcm5242-works

I used "I2C_Menu_Test" to perform the tests. This program (from the help of my consultant) allows me to read and write registry values to the device easily, to test results. In combination of Purepath studio 2, and this application, I fully understand it now and I am confident that my hardware design will work (on the DAC side, so far). I know the software drivers will be more complicated, but this is a good start so i can continue working on hardware. I figured once hardware exists it will be easier to find help. :)

==========================
My challenge: Long Lines, Multiple Lines
==========================

As I've outlined on previous posts. I plan on trying to connect up to 4 of my modules to the Teensy using a "Bridge PCB" that exposes 4 FreeDSP Expansion connectors. Each module will be connected using an IDE ribbon cable. But I'm worried about long lines. After my tests last night I can say that it will definitely be an issue. Read my log - I had some issues with multiple boards connected at the same time.

I'm going to try the pull up resistors on the I2C lines. Then it appears that the MCLK, BCLK, LRCLK can be buffered using a SN74LVC3G34 Triple Buffer Gate. I'm not sure whether or not I need to worry about the DATA lines (MDI, MDO). Does anyone here have any input on this? I need to have some stable way of connecting the bridge to the boards. Do you recommend I pursue the Buffer Gate for the clocks? Maybe a multiplexer or I2C buffer for the I2C? What about the data lines? Should I buffer them too using a gate? I guess the ADC will need a buffer for it's signal, and the Bridge will need a buffer for it's output. Is this going to be a problem?
 
Status
Not open for further replies.
Back
Top