This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

急!急!急!,ADC读出数据不对



uint ad124s021 ()

 { uint ValH,ValL;   uint i,j;  

 uint return_val=0;//返回值  

 uint ad_channel;//ADC通道  

 CS1 = 1;   CS1 = 0; //使能线   

  for (j=0;j<4;j++)//循环读两次数据,取4次的值  

 {           ad_channel = 0xc7;//通道1    

  ValH = 0;     //数据高位    

  ValL = 0;      //数据低位    

  SCLK1 = 1;     //时钟线       

   for (i = 1; i < 17; i++)    

  {       if(i<9)     { ad_channel = ad_channel << 1;  //取高位     

       DIN = CY;    

 }     

 SCLK1 = 1;      SCLK1 = 0;     SCLK1 = 1;  

   if(i>5&&i < 9)    

 {        ValH =(ValH<<1)|DOUT;        

   }             

  if (i >=9)           

    {      

ValL =(ValL<<1)|DOUT;       

    }              

  }   

  return_val+= ((ValH<<8)+ValL);   

      }

   CS1 = 1;

  return (return_val>>2);求平均数

}