Hey guys.
I've been struggling with this issue for the past few days and am hoping to find some help here.
I'm currently trying to set up a battery monitor project which uses an Arduino UNO board to read and write data from many different ADCs on the board.
The chip which I'm finding increasingly frustrating to communicate with is the LTC6803-3, whose datasheet is found here: http://cds.linear.com/docs/en/datasheet/680313fa.pdf.
Below is the code I've already tried:
#include <SPI.h>
byte WRCFG = 0x01;
byte RDCFG = 0x02;
byte RDCV = 0x04;
byte STCVAD = 0x10;
byte WPEC = 0xC7;
byte RVPEC = 0xDC;
byte RCPEC = 0xCE;
const int CS0 = 4;
const int CS1 = 5;
const int CS2 = 6;
const int DECODER_EN = 7;
const int SCKPIN = 13;
byte standby_config[6] = {0x61,0x00,0x00,0x00,0x00,0x00};
byte read_config[6] = {0x00,0x00,0x00,0x00,0x00,0x00};
void setup()
{
pinMode(CS0,OUTPUT);
pinMode(CS1,OUTPUT);
pinMode(CS2,OUTPUT);
pinMode(DECODER_EN,OUTPUT);
pinMode(SCKPIN,OUTPUT);
Serial.begin(9600);
SPI.begin();
SPI.setDataMode(SPI_MODE3);
digitalWrite(DECODER_EN,LOW);
digitalWrite(CS0,LOW);
digitalWrite(CS1,HIGH);
digitalWrite(CS2,LOW);
digitalWrite(SCKPIN,LOW);
delay(1000);
digitalWrite(DECODER_EN,LOW);
SPI.transfer(WRCFG);
SPI.transfer(WPEC);
for(int i = 0; i < 6; i++){
SPI.transfer(standby_config[i]);
}
digitalWrite(SCKPIN,HIGH);
digitalWrite(DECODER_EN,HIGH);
digitalWrite(SCKPIN,LOW);
}
void loop()
{
Serial.println("Reading config registers");
digitalWrite(DECODER_EN,LOW);
SPI.transfer(RDCFG);
SPI.transfer(RCPEC);
digitalWrite(SCKPIN,HIGH);
for(int j = 0; j < 6; j++){
read_config[j] = SPI.transfer(0);
digitalWrite(SCKPIN,LOW);
delay(100);
Serial.println(read_config[j],HEX);
digitalWrite(SCKPIN,HIGH);
}
digitalWrite(DECODER_EN,HIGH);
delay(1000);
}
What I get back is 0xFF for each config register, when I'm expecting to see 0x00. Any ideas on where to go from here?
Thanks in advance!