Hi, I'm not sure what I'm doing wrong.
Chip is IS32FL3238:
My code below attempts to set the first 5 registers in table 2 page 10 for Out 1.
Address is set to 00
i2c scanner picks up 0x34 as address.
Why can't i set or read anything correctly?
I am using an ATTiny816.
i am an electrical design engineer and I'm confident I wired up things correctly. SDB is high, AD is low, 3.3V to both attiny and led driver. current limit pin set with 3k. I2C pulled up.
// TAS6422 Diagnostics and Control Driver
// Author: Peter Bradbury
// REV 1 Aug 31 2018
// The TAS6422 is a digital class D audio amplifier with diagnostics and configuration over I2C.
// http://www.ti.com/lit/ds/symlink/tas6422-q1.pdf
// This driver:
// - Sets Misc Controls 3 as referenced on pg 43 Table 33 DONE (tested)
// - Sets the mode of both channels to PLAY (default Hi-Z) DONE (tested)
// - Sets the volume lower to approximately 30dB (default is 0dB: too loud for current speakers) DONE (tested)
// - Sets over-current limit to level 1: 4.8 A typical (default is level 2) referenced pg 33 Table 11 DONE (needs testing)
// - Sets Pin Reporting conditions referenced on pg 40 Table 25
// - Reads back load diagnostics referenced on pg 37 Table 18
// - Reads back State Reporting (channel state) referenced on pg 38 Table 20
// - Reads back Channel Faults referenced on pg 38 Table 21
// - Reads back Global Faults 1 referenced on pg 39 Table 22
// - Reads back Global Faults 2 referenced on pg 39 Table 23
// - Reads back Warnings Field referenced on pg 39-40 Table 24
// - Reads back detected Clip Warnings per channel as referenced on pg 44 Table 36
// - Reads back configured settings
#include <Wire.h>
#define tas
#define setTAS 3 // button to clear WARN pin
#define readTAS 2 // button to read TAS6422 registers over i2c
#define led1 8 // LED1 for Configure command communication indication
#define led2 9 // LED2 for READ command communication indication
#define MySerial Serial
// variables will change:
int setTASs = 0; // State variable for reading the button used to clear latched WARN pin
int readTASs = 0; // State variable for reading the button used to command i2c read
void setup() {
Wire.begin();
MySerial.begin(9600);
MySerial.println("IS323FL3238 Driver");
}
void loop() {
byte error, address; // variable for scanning all addresses
int nDevices; // number of devices on circuit
MySerial.println("IS323FL3238 Control");
MySerial.println("Scanning for device I2C address...");
nDevices = 0;
for (address = 1; address < 127; address++ ) // I2C Device Address Scanning
{
Wire.beginTransmission(address);
error = Wire.endTransmission();
if (error == 0)
{
MySerial.print("I2C device found at address 0x");
if (address < 16)
MySerial.print("0");
MySerial.print(address, HEX);
MySerial.println(" !");
nDevices++;
}
else if (error == 4)
{
MySerial.print("Unknown error at address 0x");
if (address < 16)
MySerial.print("0");
MySerial.println(address, HEX);
}
}
if (nDevices == 0)
MySerial.println("No I2C devices found\n");
else
MySerial.println("done\n");
delay(5000);
MySerial.println("Setting Software Shutdown Mode to Normal Operation");
Wire.beginTransmission(byte(0x34)); // Targeting specific device to begin communication
Wire.write(byte(0x00)); // Register address
Wire.write(byte(0x01)); // Setting bits
Wire.endTransmission();
delay(500);
// MySerial.println("reading address 00");
// Wire.beginTransmission(byte(0x34));
// Wire.beginTransmission(byte(0x69));
// Wire.write(byte(0x00));
// Wire.requestFrom(0x69,8);
// while (Wire.available()){
// byte slaveByte2 = Wire.read();
// MySerial.println(slaveByte2);
// }
// Wire.endTransmission();
// delay(500);
MySerial.println("Setting Over-Current limit to level 1");
Wire.beginTransmission(byte(0x34));
Wire.write(byte(0x03));
Wire.write(byte(0xFF));
Wire.endTransmission();
delay(500);
MySerial.println("Setting Over-Current limit to level 1");
Wire.beginTransmission(byte(0x34));
Wire.write(byte(0x01));
Wire.write(byte(0xFF));
Wire.endTransmission();
delay(500);
MySerial.println("Setting Channel 1 volume LOW");
Wire.beginTransmission(byte(0x34));
Wire.write(byte(0x49));
Wire.write(byte(0x00));
Wire.endTransmission();
delay(500);
MySerial.println("Setting Channel 1 volume LOW");
Wire.beginTransmission(byte(0x34));
Wire.write(byte(0x49));
Wire.write(byte(0x00));
Wire.endTransmission();
delay(500);
MySerial.println("Setting Channel 1 volume LOW");
Wire.beginTransmission(byte(0x34));
Wire.write(byte(0x49));
Wire.write(byte(0x00));
Wire.endTransmission();
delay(500);
//
MySerial.println("Setting Channel 2 volume LOW");
Wire.beginTransmission(byte(0x34));
Wire.write(byte(0x6E));
Wire.write(byte(0xFF));
Wire.endTransmission();
delay(500);
//
// MySerial.println("Setting Over-Current limit to level 1");
// Wire.beginTransmission(byte(0x6A));
// Wire.write(byte(0x01));
// Wire.write(byte(0b00100010));
// Wire.endTransmission();
// delay(500);
//
// MySerial.println("Setting Over-Current limit to level 1");
// Wire.beginTransmission(byte(0x6A));
// Wire.write(byte(0x01));
// Wire.write(byte(0b00100010));
// Wire.endTransmission();
// delay(500);
// Wire.requestFrom(1, 8); // Ask slave#1 for 8 bytes
//
// while (Wire.available()) {
// char c = Wire.read();
// MySerial.println(c);
// delay(500);
// }
}