CS42448 wiring - transfering a project from Teensy 3.6 to 4.0

Status
Not open for further replies.

orbital5k

New member
Hi guys,

Having a lot of fun with 4.0! My issue is:

I am attempting to port a project using the CS42448 from a Teensy 3.6 to 4.0. I have successfully rewired the PCB and now have 8 working audio outputs but I have not been able to get the inputs working.

I followed the guidance for the audio board to remap the pins to the new teensy 4.0:

TX from 22 (3.6) to 7 (4.0)
RX from 13 to 8
SDA from 18 to 18
SCL from 19 to 19
LRCLK from 23 to 20
BCLK from 9 to 21
MCLK from 11 to 23

Has anyone successfully used the CS42448 inputs on the T4.0 as of yet?

Any help with this would be greatly appreciated. I made a little PCB sub board to handle the rewiring as i have the 3.6 connected to my PCB via headers and slotting back in a 3.6 works perfectly so the hardware is sound, I think I have a mistake in the RX connection.

Should RX connect to CRX1 on the teensy 4.0? The 2 pins for CRX1 (13 and 23) are being used for SCLK & MCLK in my current wiring. I get the feeling that the issue is caused by a conflicting pin (the alternate SPI clock pin being unavailable on the T4).

The only pins in use outside of the CS42448 are for an ST7735 screen. The pins assigned are:

#define sclk 13
#define mosi 11
#define cs 10
#define dc 6
#define rst 9


If I can provide any more info just let me know and thanks for any help!
 
Last edited:
Looks like the TDM code was broken for Teensy 4.0. I've committed fixes to github.

https://github.com/PaulStoffregen/Audio/commit/9a9fff52764a69cee7f0a4bc04f4e851bb2b6fc3
https://github.com/PaulStoffregen/Audio/commit/c5a33a00498d9565afa5323a56d177f8996c7ca6

With these fixes and the wires connected as you described, I can confirm simultaneous TDM input and output works. Here it is on my desk right now, with kinda horrific wiring:

DSC_0622_web.jpg
(click for full size)

Here's the waveforms.

file.png

For testing, as you can see in the photo I just connected a stereo input to 2 of the 6 inputs, and I have a single monitor speaker connected to 1 of the 8 outputs.

I ran this program, which mixes the live input with the guitar synth example. (get chords.h from that example)

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

#include "chords.h"

// Special thanks to Matthew Rahtz - http://amid.fish/karplus-strong/

AudioInputTDM            in;
AudioSynthKarplusStrong  string1;
AudioSynthKarplusStrong  string2;
AudioSynthKarplusStrong  string3;
AudioSynthKarplusStrong  string4;
AudioSynthKarplusStrong  string5;
AudioSynthKarplusStrong  string6;
AudioMixer4              mixer1;
AudioMixer4              mixer2;
AudioOutputTDM           out;
AudioConnection          patchCord0(in, 0, mixer2, 3);
AudioConnection          patchCord1(string1, 0, mixer1, 0);
AudioConnection          patchCord2(string2, 0, mixer1, 1);
AudioConnection          patchCord3(string3, 0, mixer1, 2);
AudioConnection          patchCord4(string4, 0, mixer1, 3);
AudioConnection          patchCord5(mixer1, 0, mixer2, 0);
AudioConnection          patchCord6(string5, 0, mixer2, 1);
AudioConnection          patchCord7(string6, 0, mixer2, 2);
AudioConnection          patchCord8(mixer2, 0, out, 0);
AudioConnection          patchCord9(mixer2, 0, out, 2);
AudioConnection          patchCordA(mixer2, 0, out, 4);
AudioConnection          patchCordB(mixer2, 0, out, 6);
AudioConnection          patchCordC(mixer2, 0, out, 8);
AudioConnection          patchCordD(mixer2, 0, out, 10);
AudioConnection          patchCordE(mixer2, 0, out, 12);
AudioConnection          patchCordF(mixer2, 0, out, 14);  // listening here
AudioControlCS42448      sgtl5000_1;

const int finger_delay = 5;
const int hand_delay = 220;

int chordnum=0;

void setup() {
  AudioMemory(50);
  sgtl5000_1.enable();
  sgtl5000_1.volume(0.6);
  mixer1.gain(0, 0.05);
  mixer1.gain(1, 0.05);
  mixer1.gain(2, 0.05);
  mixer1.gain(3, 0.05);
  mixer2.gain(1, 0.05);
  mixer2.gain(2, 0.05);
  mixer2.gain(3, 0.8);  // live input
  delay(700);
}

void strum_up(const float *chord, float velocity);
void strum_dn(const float *chord, float velocity);

void loop() {
  const float *chord;

  // each time through the loop, play a different chord
  if (chordnum == 0) {
    chord = Cmajor;
    Serial.println("C major");
    chordnum = 1;
  } else if (chordnum == 1) {
    chord = Gmajor;
    Serial.println("G major");
    chordnum = 2;
  } else if (chordnum == 2) {
    chord = Aminor;
    Serial.println("A minor");
    chordnum = 3;
  } else {
    chord = Eminor;
    Serial.println("E minor");
    chordnum = 0;
  }

  // then strum the 6 string several times
  strum_up(chord, 1.0);
  delay(hand_delay);
  delay(hand_delay);
  strum_up(chord, 1.0);
  delay(hand_delay);
  strum_dn(chord, 0.8);
  delay(hand_delay);
  delay(hand_delay);
  strum_dn(chord, 0.8);
  delay(hand_delay);
  strum_up(chord, 1.0);
  delay(hand_delay);
  strum_dn(chord, 0.8);
  delay(hand_delay);
  strum_up(chord, 1.0);
  delay(hand_delay);
  delay(hand_delay);
  strum_up(chord, 1.0);
  delay(hand_delay);
  strum_dn(chord, 0.7);
  delay(hand_delay);
  delay(hand_delay);
  strum_dn(chord, 0.7);
  delay(hand_delay);
  strum_up(chord, 1.0);
  delay(hand_delay);
  strum_dn(chord, 0.7);
  delay(hand_delay);

  Serial.print("Max CPU Usage = ");
  Serial.print(AudioProcessorUsageMax(), 1);
  Serial.println("%");
}

void strum_up(const float *chord, float velocity)
{
  if (chord[0] > 20.0) string1.noteOn(chord[0], velocity);
  delay(finger_delay);
  if (chord[1] > 20.0) string2.noteOn(chord[1], velocity);
  delay(finger_delay);
  if (chord[2] > 20.0) string3.noteOn(chord[2], velocity);
  delay(finger_delay);
  if (chord[3] > 20.0) string4.noteOn(chord[3], velocity);
  delay(finger_delay);
  if (chord[4] > 20.0) string5.noteOn(chord[4], velocity);
  delay(finger_delay);
  if (chord[5] > 20.0) string6.noteOn(chord[5], velocity);
  delay(finger_delay);
}

void strum_dn(const float *chord, float velocity)
{
  if (chord[5] > 20.0) string1.noteOn(chord[5], velocity);
  delay(finger_delay);
  if (chord[4] > 20.0) string2.noteOn(chord[4], velocity);
  delay(finger_delay);
  if (chord[3] > 20.0) string3.noteOn(chord[3], velocity);
  delay(finger_delay);
  if (chord[2] > 20.0) string4.noteOn(chord[2], velocity);
  delay(finger_delay);
  if (chord[1] > 20.0) string5.noteOn(chord[1], velocity);
  delay(finger_delay);
  if (chord[0] > 20.0) string6.noteOn(chord[0], velocity);
  delay(finger_delay);
}
 
Hi Paul, thank you so much for the fast reply and going to the trouble to physically test.

I just ran the sketch below and can confirm all 6 inputs and 8 outputs are working perfectly.

Thanks again, can't wait to experiment with the new processing power!

Code:
/*
  A simple audio passthrough test for the CS42448.
  6 audio inputs.
  8 audio outputs.
*/

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

AudioControlCS42448             cs42448;                 //controller for the Teensy Audio Board
AudioInputTDM                   TDM_In;                   //Digital audio *from* the Teensy Audio Board ADC.  Sends Int16.  Stereo.
AudioOutputTDM                  TDM_Out;                  //Digital audio *to* the Teensy Audio Board DAC.  Expects Int16.  Stereo

AudioConnection          patchCord1(TDM_In, 10, TDM_Out, 14);
AudioConnection          patchCord2(TDM_In, 8, TDM_Out, 12);
AudioConnection          patchCord3(TDM_In, 6, TDM_Out, 10);
AudioConnection          patchCord4(TDM_In, 4, TDM_Out, 8);
AudioConnection          patchCord5(TDM_In, 2, TDM_Out, 6);
AudioConnection          patchCord6(TDM_In, 0, TDM_Out, 4);
AudioConnection          patchCord5(TDM_In, 0, TDM_Out, 2);
AudioConnection          patchCord6(TDM_In, 0, TDM_Out, 0);

void setup() {
  AudioMemory(80);
  cs42448.enable();
  cs42448.volume(0.5);
  cs42448.inputLevel(2.0);
}

void loop() {
}
 
Status
Not open for further replies.
Back
Top