uint32_t maxData = 0x3BCD1234; // 32 bit Max31855 küldött adata.
uint32_t xData = 0x00000000; // 32 bit átmeneti tároló.
int16_t tempKtc = 0x0000; // K tipusú szenzor hőmérséklete.
uint16_t tempChip = 0x0000; // Chip hőmérséklete.
uint8_t faultCode = 0x00; // Hibakód.
float xFloat = 0;
float fKtc = 0;
float fChip = 0;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.print("maxData: 0x");
Serial.println(maxData, HEX);
Serial.print("maxData: B");
Serial.println(maxData, BIN);
tempKtc = maxData >> 18;
tempChip = maxData >> 4;
tempChip = tempChip & 0x0FFF;
faultCode = maxData & B00000111;
if (bitRead(tempKtc, 13) == 1){
tempKtc = tempKtc | 0xC000;
}
if (bitRead(tempChip, 11) == 1){
tempChip = tempChip | 0xF000;
}
Serial.print("tempKtc: B");
Serial.println(tempKtc, BIN);
Serial.print("tempChip: B");
Serial.println(tempChip, BIN);
Serial.print("faultCode: B");
Serial.println(faultCode, BIN);
Serial.println("-------");
tempKtc = 0xFFFF;
//tempKtc = ~tempKtc + 1;
//Serial.println(tempKtc,BIN);
xFloat = (float) tempKtc;
xFloat = xFloat * 0.25;
Serial.println(xFloat);
Serial.println("-------");
}
void loop() {
// put your main code here, to run repeatedly:
}