title: typecasting char variable into unsigned int
body: <p>I am trying to convert char variables into Unsigned int. my code is</p>
  
  <pre><code>char spi(char data) 
  { 
      //Start transmision 
      SPDR = data; 
      //Wait for transmision complete 
      while(!(SPSR &amp; 0x80)); 
      return SPDR; 
  } 
  
  unsigned int ReadAd(void) 
  { 
      unsigned int data; 
  
      ChipSelectAd(1); 
      //Read data 
      CheckStatus();                                            
      spi(0x58);                                                
      data = (spi(0xFF)&lt;&lt; 8);    
      data |= spi(0xFF);         
  
      return data; 
  } 
  </code></pre>
  
  <p>Actually my problem is The spi function return an 8bit char so the above code shifts left 8bits the char variable and then assigns it to a 16bit variable, the result will always be 0.
  In order to actually shift the data to the left I need to typecast them first to a 16bit type variable. I have tried like this </p>
  
  <pre><code>char spi(char data) 
  { 
      //Start transmision 
      SPDR = data; 
      //Wait for transmision complete 
      while(!(SPSR &amp; 0x80)); 
      return SPDR; 
  } 
  
  unsigned int ReadAd(void) 
  { 
      unsigned int data; 
  
      ChipSelectAd(1); 
      //Read data 
      CheckStatus();                                            
      spi(0x58);                                                
      data = (unsigned int)((unsigned char)spi(0xFF)&lt;&lt; 8);    
      data |= (unsigned int)((unsigned char)spi(0xFF));         
  
      return data; 
  } 
  
  void CheckStatus(void)
  {
  //char adcStatus;
  adcStatus = 0xFF;                                           
  //Read status
  while(!(adcStatus &amp; 0x80))
  {
      spi(0x40);
      adcStatus = spi(0xFF);
   }
  }
  
  void ChipSelectAd(char s)
  {
  
  
  if(s == 1){
      PORTB.3 = 0;    //Switch on ADC
      //while(PINB.3);  //Wait for chip select pin
  }
      else
          PORTB.3 = 1;    //Switch off ADC
   }
  </code></pre>
  
  <p>its not working. please suggest me which function i have to use.</p>
  
  <p>Thanks in advance.</p>