I cant understand the output, but I think the layout works.
Output Data Format
The LTC2433-1 serial output data stream is 19 bits long.
The first 3 bits represent status information indicating the
conversion state and sign. The next 16 bits are the conver-
sion result, MSB first. The third and fourth bit together are
also used to indicate an underrange condition
I just saw you connected CS to GND. That way the chip does not know when to do a conversion and when to start a transmission. Take a look at the timing diagram on page 13 of the datasheet. The CS pin is needed in my reading of the datasheet.
Yes, but then you must monitor the DSO line for the EOC (End Of Conversion) state and you don't do that. I would even turn off SPI after each transfer, set PB3 to GPIO input, pull CS low and wait until PB3 gets low. Then activate SPI and read the bytes. Maybe it's easier to do that without the hardware SPI and use just the shiftIn() functions.
I've got chip select on, it did not change anything.
I have a big problem, there must be a hardware problem.
Hope I can get help on the job tomorrow, then I will return.
I've added setClockDivider because the LTC2433 can not run more than 4MHz, DIV32 gives 500KHz
SPI.setClockDivider(SPI_CLOCK_DIV32);
Here is the entire code
#include "SPI.h"
byte byte1; byte byte2; byte byte3;
// declare 3 bytes = 24 bits
//Setup the CS
int CSPin = 10;
void setup(){
pinMode(CSPin, OUTPUT);
digitalWrite(CSPin, HIGH);
SPI.begin(); // wake up the SPI bus.
SPI.setBitOrder(MSBFIRST);
SPI.setDataMode(SPI_MODE0);
SPI.setClockDivider(SPI_CLOCK_DIV32); //32 = 500KHz Må max være 2MHz
Serial.begin(19200);
}
void loop()
{
delay(2000);
digitalWrite(CSPin, LOW);
delay(1);
byte1 = SPI.transfer(0);
byte2 = SPI.transfer(0);
byte3 = SPI.transfer(0);
delay(1);
digitalWrite(CSPin, HIGH);
uint16_t v = byte1;
v <<= 11;
v |= ((uint16_t) byte2) << 3;
v |= byte3 >> 5;
int16_t value = (byte1 & 0x20) ? -v : v;
Serial.println(value);
}
Because the ADC can convert positive and negative voltages. You can change that either in the hardware or just remove the addition of the sign in the code, e.g. this line: