i don't know the OWS DS18b20, but could you confirm :
you take 2 bytes from DS18b20, but only keep MSB of each value to form the result
is it the good way ?
does it needs to use an integer to contain the result ?
i don't know the OWS DS18b20, but could you confirm :
you take 2 bytes from DS18b20, but only keep MSB of each value to form the result
is it the good way ?
does it needs to use an integer to contain the result ?
İ need MSB of first byte (4 bits) and lsb of second byte (4bits). And first 4 bits will be my lsb and second 4 bits will be my MSB on the result byte.
İ dont know If read_byte function gets the correct value. But If i assign values for MSB And LSB variables on read_temperature function it is giving the correct values(the values i assigned) on the LCD . So read_byte function seems to be not getting bytes from ds18b20.
- - - Updated - - -
unsigned char read_temperature(void){ // Buffer length must be at least 12bytes long! ["+XXX.XXXX C"]
unsigned char LSB,MSB;
unsigned char digit=0; //Reset, skip ROM and start temperature conversion
bus_reset();
write_byte(CMD_SKIPROM);
write_byte(CMD_CONVERTTEMP);
DelayMs(750); //Wait until conversion is complet
bus_reset(); //Reset, skip ROM and send command to read Scratchpad
write_byte(CMD_SKIPROM);
write_byte(CMD_RSCRATCHPAD);
LSB=read_byte(); //here if I put LSB=0b11001111 ; instead of read_byte function
MSB=read_byte(); // here if I put MSB=0b11111001 ; instead of read_byte function then im getting the digit
// variable (return value) like 10011100 which is -100 and it is appearing on lcd.use
// but if i use read_byte function then it is not working. so here there is something wrong
//with the functions for 1 wire bus communication but i could see nothing wrong.
bus_reset(); //Store temperature integer digits
digit=LSB>>4;
digit|=(MSB&15)<<4;
return digit;
}
I read the datasheet, and it seems that all the Scratchpad must be read (9 bytes) ?
Unfortunatly, i don't have this device to check by myself.
You don't check (read) the DS18b20 "Presence pulse" before start Skip ROM + Read Scratchpad ..
to be sure DS18B20 is visible on the OWS bus.
Are you confident with your delay_uS to build mS delay ?
maybe you can use a timer to do delay 750mS ?
I read the datasheet, and it seems that all the Scratchpad must be read (9 bytes) ?
Unfortunatly, i don't have this device to check by myself.
You don't check (read) the DS18b20 "Presence pulse" before start Skip ROM + Read Scratchpad ..
to be sure DS18B20 is visible on the OWS bus.
Are you confident with your delay_uS to build mS delay ?
maybe you can use a timer to do delay 750mS ?