Stayed up half the night - no dice.
Went to bed, tossed an turned, woke up, saw the mistake,
GOT IT WORKING
View attachment 001_Proto003.jpg
The first test is to read the configuration registers.
There are 6 configuration registers. The default value for the first register should be 0xEF.
Here is what I drove it with:
0x02 // Command "Read Control Registers"
0x02 // Pump in 6 registers
0x02
0x02
0x02
0x02
0x02 // CRC
(Only the first byte matters, the rest are just placeholders. With SPI the master must always drive the clock so you are arbitrary pumping out data no matter what)
Here is what I got for a response:
FF // idle while driving command
E0 // First byte as expected!
0 // bytes 2-6 as expected
0
0
0
0
A1 // the CRC
CRC is 8 bit: x^8 + X^2 + X + 1
Checking this really quick with an online CRC calculator
http://smbus.org/faq/crc8Applet.htm
A1 is in fact the correct checksum for E00000000000.
Here is the code I used. This is Arduino code.
The general idea is that I call an SPI library that sets up the SPI pins
I set up the port per the datasheet
I wait for the user to enter a command, convert it from ASCII to HEX, drive chip select, send the command, read back 6 bytes, read back the CRC, then print the results back on the USB port.
//*****************************************************************************
[pre]#include <Spi.h>
// Driver for the LTC6802-1
// Monitor only - 36 cells
//pin 13 SCK_PIN SPI clock
//pin 12 MISO_PIN SPI master in, slave out
//pin 11 MOSI_PIN SPI master out, slave in
//pin 10 SS_PIN SPI slave select
#define TALK digitalWrite(SS_PIN, LOW); // Chip Select
#define DONE digitalWrite(SS_PIN, HIGH); // Deselect
// LTC6802-1 Command Codes (short list)
#define WRCFG 0x01 // Write config
#define RDCFG 0x02 // Read config
#define RDCV 0x04 // Read cells
//#define RDFLG 0x06 // Read flags
#define RDTMP 0x08 // Read Temps
#define STCVAD 0x10 // Start all A/D's - poll status
#define STOWAD 0x20 // Start testing all open wire - poll status
#define STTMPAD 0x30 // Start temperatures A/D's - poll status
void setup()
{
// SPI Configuration
// No interupt, Enable SPI, MSB first, Master, Clock rests high,
// Read on rising edge, 1Mhz speed
DONE // Set CS High
Spi.mode((1<<SPE) | (1<<MSTR) | (1<<CPOL) | (1 << CPHA) | (1 << SPR1) | (1<<SPR0) );
Serial.begin(9600);
}
void loop() {
byte userInput;
byte ltcResponse[9];
if (Serial.available())
{
userInput = (Serial.read()) - 0x30; // convert from ASCII
TALK
for(int i=0; i<8; i++)
ltcResponse
= Spi.transfer(userInput); // Command
DONE
for(int i=0; i<8; i++)
Serial.println(ltcResponse, HEX);
}
}[/pre]
//*****************************************************************************
Methods >= happy
-methods