SGTL5000 line-out sometimes doesn't work?

Status
Not open for further replies.

prajtm

Member
Hey all. I'm using a teensy 4.1 on a custom PCB with the audio shield replicated on it, and I'm facing an issue where I'm sometimes getting little to no signal on the SGTL5000's line-output, which I have hooked up to my audio interface.

When I upload the PlaySynthMusic example sketch that comes with the Audio library, the line-out and the headphone out both work fine. However, when I upload my own code, the headphone output works fine, but I'm getting only a very small signal on line-out(checked it with scope) which is not really useable. What's weird is that in my code, I setup and enable the codec in the exact same way as the example sketch, yet, for some reason, the line output just doesn't work.

So I know it's some issue with the code and not the hardware, but I haven't been able to track it down. I even tried explicitly setting lineOutLevel and unmuteLineout to no effect. Does anyone know what might be causing this? I'm stumped.

I've attached my entire code as a zip, but the following are the only places where I address the codec directly in my code:

Code:
//audio network
AudioControlSGTL5000     codec; 

void setup() {
  codec.enable();
  codec.volume(0.45);
  
  //other stuff
}

void loop() {
  int n = analogRead(15);
  if (n != vol) {
    vol = n;
    codec.volume((float)n / 1023);
  }

  //other stuff
}

View attachment 1_CombinedSystem.zip
 
You should be calling codec.lineOutLevel (). the volume method is for headphones only I'm pretty sure.
 
Oh yeah, I only intended for the headphone volume to be controlled. I want the line-out level to stay at its default (29) all the time.

I tried adding codec.lineOutLevel (29) in the loop() to see if that would help anything, but I'm still getting the same results, i.e. a very tiny/no signal on line-out. And like I said, changing it to lineOutLevel (13) doesn't help either.
 
I'm not ruling it out, but I do think that a hardware issue is unlikely. Its pretty much a direct connection to the SGTL5000's line-out pins (through dc blocking caps ofc) and more importantly, line-out works fine when I run the PlaySynthMusic example sketch
 
I stand corrected. I put the audio ground loop noise isolator thing between my board (which was being powered via usb) and my interface, and now line-out is working as expected. I guess it some kind of a hardware issue. I have no idea why this changed anything but I'm glad it's working now. If anyone has any insight about why this fixed the problem, I would love to know.
 
Status
Not open for further replies.
Back
Top