Hi, I am trying to design low cost audio amplifiers for headphones with volume control (I2C) using ATMEGA328. So I want to deactivate class D amplifiers, activate only DirectPath for headphones. For now I am just trying to give a fixed volume. I checked the voltage levels at input, its around 0.25/0.11V and varying. However, I am not getting any output signal from TPA2050D4. Also, I am not sure if I am coding the device TPA2050D4 right. Not sure if its the coding issue, or my schematics, or if TPA2050D4 is compatible with ATMEGA328. Can anyone please help me on where I could be wrong.
#include <Wire.h> #include <avr/sleep.h> int num=0; void setup() { Wire.begin(); pinMode(A3, OUTPUT); digitalWrite(A3, HIGH); pinMode(3,OUTPUT); //debug to led 3 //power amp setup Wire.beginTransmission(0xE0); //write enable register if(Wire.available()) { num = 1; } Wire.write(0x02); // register address 0X02 if(Wire.available()) { num = 1; } Wire.write(0x0C); // SWS '0', HPL and HPR enabled, class D disable if(Wire.available()) { num = 1; } Wire.endTransmission(); delay(100); Wire.beginTransmission(0xE0); //write enable register if(Wire.available()) { num = 1; } Wire.write(0x03); // register address was 0X03 if(Wire.available()) { num = 1; } Wire.write(0x81); // LIM_LOCK enable, mode 001, I want this at the heaphones if(Wire.available()) { num = 1; } Wire.endTransmission(); delay(100); Wire.beginTransmission(0xE0); if(Wire.available()) { num = 1; } Wire.write(0x05); // register address was 0X05 if(Wire.available()) { num = 1; } Wire.write(0x13); // volume num = 1; } Wire.endTransmission(); delay(100); Wire.beginTransmission(0xE0); if(Wire.available()) { num = 1; } Wire.write(0x06); // register address was 0X06 if(Wire.available()) { num = 1; } Wire.write(0x13); // volume data if(Wire.available()) { num = 1; } Wire.endTransmission(); delay(100); Wire.beginTransmission(0xE0); if(Wire.available()) { num = 1; } Wire.write(0x07); // register address was 0X07 if(Wire.available()) { num = 1; } Wire.write(0x12); // HP voltage and gain if(Wire.available()) { num = 1; } Wire.endTransmission(); delay(100); } void loop() { if(num ==1){ digitalWrite(3,HIGH); } }