Okay I am trying from the suggestions provided but am getting limited results.
Here is the code I am trying, but it is returning is 25 bits. I am sure I am making an idiot mistake here
The serial output is
"1000000010000000100000001"
/***************************************************
* Custom MAX31855 Library using hardware based SPI.h
/****************************************************/
#include <SPI.h>
union FourByte{
unsigned long bit32;
unsigned int bit16[2];
unsigned char bit8[4];
};
int SlavePin1 = 4; //Thermocouple #1
long unsigned data;
void setup() {
Serial.begin(9600);
pinMode(SlavePin1, OUTPUT);
digitalWrite(SlavePin1, HIGH); //Disable SS
SPI.begin(SlavePin1); // Setup SPI to use pin 4 as CS.
SPI.setBitOrder(MSBFIRST);
SPI.setDataMode(SlavePin1,1); // Use SPI Mode 1 (CPOL = 0, CPHA = 1)
SPI.setClockDivider(SlavePin1, 21); // Set SPI Clock divider to 21.(4MHz)
}
unsigned long transfer(unsigned long value){
FourByte data = {value};
for(byte i = 0; i < 4; i++){
data.bit8[i] = SPI.transfer(SlavePin1, data.bit8[i]);
delay(1);
}
return data.bit32;
}
void loop() {
digitalWrite(SlavePin1, LOW);
unsigned long someValue = 0xFFFFFFFEUL; //No MOSI on MAX31855, dosent matter what is sent.
data = transfer(someValue);
Serial.println(data, BIN);
digitalWrite(SlavePin1, HIGH);
delay(1000);
}
Oh one last thing.... the Datasheet for the MAX31855 states the following:
Drive CS low to output the first bit on the SO pin. A
complete serial-interface read of the cold-junction compensated thermocouple temperature requires 14 clock
cycles. Thirty-two clock cycles are required to read both
the thermocouple and reference junction temperatures
With my for loop only cycling 3 times, is this my issue? If so how can my code be modified to the same end result of bringing out all 32 binary bits in the serial interface. If thats working I can get to my final goal from there.