hI GUYS
I need some help to ensure my understanding of how this is supposed to work.
I have found a sketch online to drive my max6675 using the spi library i.e. hardware spi bus on the uno.
I want to know given the attached serial timing diagram which spi mode should I use?
Based on my newly found knowledge I believe it should be mode 1
Is this correct?
void setup(){
pinMode(9,OUTPUT); // configure MAX6675 CS pin
digitalWrite(9,HIGH); // tell MAX6675 to read sensor
SPI.begin();
Serial.begin(9600);
}
int readTemp(){
SPI.beginTransaction((SPISettings(1000000, MSBFIRST, SPI_MODE1))); // configure the SPI for this device
digitalWrite(9,LOW); // I am now talking to the MAX6675
uint16_t reading=SPI.transfer16(0); // read 16bits
Serial.println("current reading:");
Serial.print(reading);
digitalWrite(9,HIGH); // I am done Talking to the MAX6675
SPI.endTransaction(); // release the SPI bus for others to use (i.e. SD, ethernet)
if (reading & 0x0004){// sensor disconnected
reading = -1;
}
else {
reading = reading >>3; // the reading is in bits 14..03, get rid of bit 2,1,0
}
return reading;
}
void loop()
{
readTemp();
}