Trouble Communicating with TDA7419 Audio Preamp over I2C

Hey all,

For some time now I've been working on a diy head unit (car stereo) and have for the most part been doing pretty well. Unfortunately I'm having trouble communicating with my audio preamp, a TDA7419, over I2C. Before I go any further, here's a link to the datasheet: https://www.st.com/resource/en/datasheet/tda7419.pdf

I do know that the preamp is present on the bus from running an I2C scanner which picked it up at 0x44, which is correct based on the datasheet. Unfortunately I either cannot seem to write to it or read from it, not sure which, or it could be both.

For the sake of example, here's a snippet that I would think should set the main source selector (register 0x00) to input SE3 (0x03). It's nerfed to basics for readability at testing; this is not how it would be implemented.

#include <Wire.h>

#define ADDRESS 0x44

int num;

void setup() {
  Serial.begin(9600);
  Wire.begin();

  Wire.beginTransmission(ADDRESS);
  Wire.write(0x00); //write command byte for main source selector
  Wire.write(0x03); //write value for input SE3
  Wire.endTransmission();


  Wire.beginTransmission(ADDRESS);
  Wire.write(0x00); //write command byte for main source selector
  Wire.endTransmission();
  
  Wire.requestFrom(ADDRESS, 1); //request one byte from main source selector
  num = Wire.read(); //read byte and store in num
  Serial.println(num);
}

void loop() {
  
}

For whatever reason all I ever see come back on the serial monitor is a "1". That's the case no matter if I re-order some parts of the read portion, get rid of num and just print Wire.read() directly, etc. I'm sure I'm missing something, but for the life of me I can't figure out what (for context, I started this project nearly a year ago and took a break due to this issue/a faulty regulator/lack of time). It's also entirely possible that I've misunderstood the datasheet.

While it shouldn't make a difference, I should note that this is being done on a 1284P.

Any advice is appreciated.

may be some food for thoughts there (and in the mbed code library)

Thanks for the link, although I already came across that about a year ago - it's a cool project though, and somewhat similar to what I'm doing. I actually based my library off his, however I've nearly double the capabilities at this point as with his was limited to mainly indirect commands (increase this, decrease that, etc). I've also added a few that simply were not present, and of course this is for Arduino and not mbed so under the hood it's a little different as well.

That said, I actually "resolved" my issue early this morning, and I say "resolved" because I'm not certain what exactly solved it. Essentially, the code I had originally written ended up working (in fact my never tested library that I began nearly a year ago worked as well). It seems that I just didn't realize how many registers needed to be set in order to get sound out. After setting eight different registers for inputs, volume, loudness, speaker attenuators, etc. I finally got some sound out, and now I'm running through - quite literally right now, vscode is up on one of my other monitors - making sure stuff works as intended.

I also ended up swapping chips with a spare I had; not sure if that had anything to do with it as they both showed up on the bus and acted identical, until I figured out how many registers needed to be set without a power cycle. Additionally I tried another I2C library, which is actually how I got it to work the first time. After that I did the same test with the Wire library again and it proved successful, which was nice since my library was already based on it.

I should also note that I still am unable to read registers. Not exactly sure if that's because this chip simply doesn't allow it (it has a transmit mode so...?) or if it's a code issue. Either way I can get around it by initializing all registers to preset values and then simply keeping track of them from there on out. Not a perfect solution, but it should work well enough.

Once I've got this library all sorted I'll try to get it up and available for anyone who may be interested in doing something similar - the TDA7419 is a pretty great little chip for projects like these from what I've seen so far.

Thanks again for the response.

Good to hear you got it working!