Hi, thanks for looking.
I'm working with the TAS6422 from TI. A class D audio amp with I2C diagnostics + control
The I2C address pins pulled low give me a write address of 0xD4 and read address of 0xD5. My first task is to clear the latched WARN pin by writing bit 7 high on register 0x21.
Page 43 table 70 + figure 33 says I would want to write bit 7 high and all the others low.
This is the part of the code I'm having trouble with:
Wire.beginTransmission(byte(0xD4)); // device address for writing
Wire.write(byte(0x21)); // register address
wire.write(byte(1000000)); // set bit 7 (clear WARN) high; set bits [6:0] low
wire.endTransmission(); // end transmission
I don't know how to specify a 1 for the 7th bit. Page 43, figure 70 + table 33 says I should write bit 7 high. I'm a newb. Why does it say address = 0x21 but then says default is 0x00? Is that the bit settings 0x00? The other registers have other defaults, but I dont see how they correlate to 1's and 0's in binary.
This is my whole code as of now. It's not done yet. : (I was using LED for debuging while a coworker was using my ftdi cable i was gonna use for serial monitor)
#include <Wire.h>
#define tas
#define clrWARN 3 // button to clear WARN pin
#define readTAS 2 // button to read TAS6422 registers over i2c
#define led1 8 // LED1
#define led2 9 // LED2
// variables will change:
int clrWARNs = 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() {
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(clrWARN, INPUT);
pinMode(readTAS, INPUT);
Wire.begin();
Serial.begin(9600);
Serial.println("TAS6422 Diagnostics");
}
void loop() {
clrWARNs = digitalRead(clrWARN);
readTASs = digitalRead(readTAS);
if (clrWARNs == HIGH) {
digitalWrite(led1, HIGH);
Wire.beginTransmission(byte(0xD4));
Wire.write(byte(0x21));
Wire.write(byte(1000000));
delay(500);
}
else {
digitalWrite(led1, LOW);
}
if (readTASs == HIGH) {
digitalWrite(led2, HIGH);
Wire.requestFrom(1, 8); // Ask slave#1 for 8 bytes
while (Wire.available()) {
char c = Wire.read();
Serial.println(c);
delay(500);
}
}
else {
digitalWrite(led2, LOW);
}
}