title: Can't extract an integer from a thermometer byte reading
body: <p>Afternoon all,</p>
  
  <p>Apologies if this question is in the wrong format or in the wrong place, if this is the case, please flag and I'll change it or take it elsewhere.</p>
  
  <p>I am using a development board to send a temperature reading to an LCD panel and I am really struggling to comprehend as to why the temperature at the moment that the program is run isn't being printed onto my LCD. A lot of the code is from framework given to me and is correct as far as I can tell.</p>
  
  <p>My question stems from these functions:</p>
  
  <pre><code>uch get_temp()
  {
      int i;
      DQ_HIGH();
      reset();                              //reset,wait for  18b20 responsion
      write_byte(0XCC);                     //ignore ROM matching
      write_byte(0X44);                     //send  temperature convert command
      for(i=20;i&gt;0;i--)
          {
  
              //display();                    //call some display function,insure the time of convert temperature
          }
      reset();                              //reset again,wait for 18b20 responsion
      write_byte(0XCC);                     //ignore ROM matching
      write_byte(0XBE);                     //send read temperature command
      TLV=read_byte();                      //read temperature low byte
      THV=read_byte();                      //read temperature high byte
      DQ_HIGH();                            //release general line
      TZ=(TLV&gt;&gt;4)|(THV&lt;&lt;4)&amp;0X3f;            //temperature integer
      TX=TLV&lt;&lt;4;  //temperature decimal
  
      if(TZ&gt;100) 
      {
          TZ/100; 
      }                   //not display hundred bit
  
      ge=TZ%10;                     //integer Entries bit
      shi=TZ/10;                    //integer ten bit
      wd=0;
  
  if (TX &amp; 0x80) 
      wd=wd+5000;
  
  if (TX &amp; 0x40) 
      wd=wd+2500;
  
  if (TX &amp; 0x20) 
      wd=wd+1250;
  
  if (TX &amp; 0x10)
      wd=wd+625;                //hereinbefore four instructions are turn  decimal into BCD code
  
      shifen=wd/1000;                          //ten cent bit
      baifen=(wd%1000)/100;                    //hundred cent bit
      qianfen=(wd%100)/10;                     //thousand cent bit
      wanfen=wd%10;                            //myriad cent bit
      NOP();
      return TZ;
  }
  </code></pre>
  
  <p>I have modified this function so that it should return the temperature integer (unsigned char TZ)</p>
  
  <p>This function is then called here:</p>
  
  <pre><code>void Init_lcd(void)
  {
      ADCON1 = 0x07; //required setting of analog to digital
  
      uch Temp;
  
      TRISD = 0x00;
      TRISA1 = 0;
      TRISA2 = 0;
      TRISA3 = 0;
  
      writeCommand(0x0f);
      writeCommand(0x38); //set to two line mode
      clearDisplay();
  
      writeString("MAIN MENU");
      Temp = get_temp();
      writeString(Temp);
      writeCommand(0xC0); //change cursor line
  
  }
  </code></pre>
  
  <p>It isn't printing anything after "MAIN MENU", which obviously means I'm doing something wrong. I can provide further clarification/code on request.</p>
  
  <p>I should probably mention that I am NOT only simply looking for an answer of "paste this in and it'll work". Any feedback in which I understand my mistake and how to fix it is greatly appreciated. </p>
  
  <p>Thanks in advance!</p>
  
  <p>EDIT:</p>
  
  <p>A few people are asking about my writing functions so for further clarification I'll paste them here:</p>
  
  <pre><code>void writeChar(unsigned char ch)
  {
      lcd = ch;
      RS = 1;
      RW =0;
      E = 1;
      lcdDelay();
      E=0;
  }
  
  void writeString(char *stringToLcd)
  {
      while(*stringToLcd &gt; 0)
      {
          writeChar(*stringToLcd++);
      }
  }
  </code></pre>