Datasheet

LCD_D5_Direction : sbit at DDRD.B5;
LCD_D6_Direction : sbit at DDRD.B6;
LCD_D7_Direction : sbit at DDRD.B7;
// End Lcd module connections
// OneWire pinout
var OW_Bit_Write : sbit at PORTB.B2;
OW_Bit_Read : sbit at PINB.B2;
OW_Bit_Direction : sbit at DDRB.B2;
// end OneWire definition
// Set TEMP_RESOLUTION to the corresponding resolution of used
DS18x20 sensor:
// 18S20: 9 (default setting; can be 9,10,11,or 12)
// 18B20: 12
const TEMP_RESOLUTION : byte = 9;
var text : array[9] of byte;
temp : word;
procedure Display_Temperature( temp2write : word );
const RES_SHIFT = TEMP_RESOLUTION - 8;
var temp_whole : byte;
temp_fraction : word;
begin
text := '000.0000';
// check if temperature is negative
if (temp2write and 0x8000) then
begin
text[0] := '-';
temp2write := not temp2write + 1;
end;
// extract temp_whole
temp_whole := word(temp2write shr RES_SHIFT);
// convert temp_whole to characters
if ( temp_whole div 100 ) then
text[0] := temp_whole div 100 + 48
else
text[0] := '0';
text[1] := (temp_whole div 10)mod 10 + 48; // Extract tens digit
text[2] := temp_whole mod 10 + 48;
// extract temp_fraction and convert it to unsigned int
299
MIKROELEKTRONIKA - SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroPASCAL PRO for AVR
CHAPTER 6