Teensy 4.0 Audio Shield Not Enabling

Hello all,

I have been working on my teensy 4.0 project that takes a signal from the line in pins from the audio shield and performs a spectrum analysis. However, I have been having trouble getting the Audio shield to work. I have soldered the pins in the correct orientation and made sure each connection is connecting the pin to the ring around the through-hole. I have not soldered anything apart from the main two rows of pins. I am connecting the Teensy 4.0 to my MacBook usb-c port via a usb-c to usb-a adapter. Here is the code that I am running to check whether the audio board is working properly. I am checking if the audio shield is able to enable or not.

C++:
#include <Audio.h>
#include <Wire.h>

AudioSynthWaveform    waveform1;
AudioOutputI2S        i2s1;
AudioConnection       patchCord1(waveform1, 0, i2s1, 0);
AudioConnection       patchCord2(waveform1, 0, i2s1, 1);
AudioControlSGTL5000  sgtl5000_1;

void setup() {
  Serial.begin(115200);
  Serial.println("Initializing...");

  if (sgtl5000_1.enable()) {
    Serial.println("Initialized audio shield");
  } else {
    Serial.println("Failed to initialize audio shield");
  }
}

void loop() {
  // Main loop code
}

A couple of things happen when running this code. Firstly, the serial output returns that the audio shield has failed to initialize. Secondly, the teensy 4.0 disconnects and disappears from the port (just after the LED light on the teensy blinks red). There is also sometimes a pop-up notification on my MacBook that says "USB Accessories Disabled – Unplug the accessory using too much power to re-enable USB devices". I would love to know if there is something obvious that I am doing wrong – I have soldered all the pins between the audio shield and the teensy 4.0. I am using the Arduino IDE setup as the initial "Download/Install" page on the pjrc website states. Any help/advice would be appreciated – please do let me know if you require any further information. Moreover, not sure if this is of any relevance, but when measuring the DC voltage between GND and any of the pins from the 3.5mm jack component, there is no voltage registered. I saw somewhere that this is the case if there is no audio signal passing through to this component – is that the case?

I am thinking that this could be an issue with how the teensy is connected to the MacBook and maybe it should be connected through a powered USB hub? Does this sound like a software issue more than a hardware issue?


Thanks in advance for your help – I hope I can get this to work soon as it is for an upcoming deadline!
 
Before you enable the audio, allocate some memory:
Code:
  AudioMemory(8);

The message "Unplug the accessory using too much power" suggests that there's a problem with your soldering somewhere. Can you post a clear photo of your audioboard?

Pete
 
Hey Pete,

Here are a few images of the soldering on the perfboard that my teensy project is on. The project also consists of a dog-m LCD, which is used to display information about the spectrum analysis performed on the input signal. The LCD was disconnected to the teensy 4.0 5v and gnd for troubleshooting purposes (the connecting wires are circled in yellow with arrows pointing to where they were previously connected to).

I've added this code to the setup:

C++:
void setup() {
  Serial.begin(115200);
  Serial.println("Initializing...");
  AudioMemory(8);
  if (sgtl5000_1.enable()) {
    Serial.println("Initialized audio shield");
  } else {
    Serial.println("Failed to initialize audio shield");
  }
}

However, this still returns a failed initialisation in the serial output. Also, once I ran this code, the teensy 4.0 disconnected and I had to reset the teensy by holding down the reset button for 15 seconds. However, when I run the code without the memory allocation, it runs (doesn't enable) but it doesn't disconnect after running. Thanks for your help!
 

Attachments

  • Screen Shot 2024-07-21 at 21.08.35.png
    Screen Shot 2024-07-21 at 21.08.35.png
    573.5 KB · Views: 35
  • Screen Shot 2024-07-21 at 21.15.43.png
    Screen Shot 2024-07-21 at 21.15.43.png
    1 MB · Views: 70
  • Screen Shot 2024-07-21 at 21.15.35.png
    Screen Shot 2024-07-21 at 21.15.35.png
    1.3 MB · Views: 81
  • Screen Shot 2024-07-21 at 21.15.25.png
    Screen Shot 2024-07-21 at 21.15.25.png
    1.1 MB · Views: 46
  • Screen Shot 2024-07-21 at 21.08.37.png
    Screen Shot 2024-07-21 at 21.08.37.png
    556.3 KB · Views: 33
Last edited:
I tried using a different macbook (I think there were existing issues with the ports on the current one I was using) and ran the guitar sythesis example code and it worked! So I think this was just an issue with the computer I was using. Thanks for your help though Pete!
 
Hey guys, I seem to be facing the same problem again even while using a different computer. This is really frustrating – it was working earlier and now its beginning to disconnect from the port whenever I run any audio-related code. Any help would really be appreciated as i have been trying to figure this out for a while now! I ran a verbose upload/compile output and saw that there were duplicated SD.h files, so I removed one of them. Not sure if that is relevant – maybe it is a software-related issue? I'm really running out of ideas as to what to do here now 😭😭😭
 
Are these all Macintosh computers with USB-C ports?

They might be looking for 5.1K pulldown resistors on the CC pins to know what type of power to send. If you have USB cables that only have wires and lack those resistors, most PCs will default to supplying regular USB power but Apple tends to rigidly follow the specs and might not supply power.

Simplest solution is usually to add a USB hub with ordinary old-style USB-A ports for the downstream devices. Plug the cable going to Teensy into one of those ports.
 
Hey, yeah they have all been Macbooks with usb-c ports. I have been using an Apple usb-c to usb-a adapter (designed by apple) to power and communicate with the teensy. When the teensy 'disconnects from the port', power is still being supplied but no communication. When you say USB hub, are you talking about a powered USB hub? What would the difference between the hub and the adapter I am currently using be? Should I maybe just try to prototype this using a windows PC instead? Thanks!
 
Last edited:
Seems like this is a repeat of this post back in Dec 2019 (https://forum.pjrc.com/index.php?th...-power-disconnects-beginner.58619/post-223165) but it was never answered. When I try to load the guitar synthesis example through the teensyloader, loading, erasing and downloading all work fine but the reboot seems to crash the teensy as it then disconnects from the port.

Some additional information that might help debug the issue: I am running the CPU speed at 24 MHz to communicate with the DOG-M LCD as the LCD is compatible with the teensy 3.0, and the 4.0 operates at too high of a frequency to work with the LCD. Seems to run absolutely fine without any Audio related code.
 
Last edited:
Have you tried to include CrashReport() support in the setup() function as follows:

Code:
while(!Serial) ;
if (CrashReport)
Serial.print(CrashReport);

Note that with the Crash Report monitor written this way (specifically, the while(!Serial);), it will wait forever if the Serial Monitor is not connected, so this added code should be commented out and/or removed after you've identified & resolved the cause of your crash.

Mark J Culross
KD5RXT
 
Back
Top