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.

AD问题,在12864上显示到不了0V



void ADC_Init(void)

{     P6SEL|=0x01;   

  ADC12CTL0=ADC12ON+SHT0_2+MSC;

ADC12CTL1=SHP+CONSEQ_2;   

  ADC12IE=0X01;    

ADC12CTL0|=ENC;//AD转换使能   

  ADC12CTL0|=ADC12SC;//开始转换  

__bis_SR_register(GIE);//使能全局中断

  }

 

unsigned int Num2Volt(unsigned int num,unsigned char *volt)

{    

unsigned int Quotient,Balance,i=0,j,k;    

 unsigned long caltmp;   

  unsigned int Curr_Volt;       

  caltmp=num;    

 caltmp=(caltmp<<5)+num;    

 caltmp=(caltmp<<6)+(caltmp<<5)+(caltmp<<1);   

  Curr_Volt=(caltmp>>12);  //转换成毫伏    

 Quotient=Curr_Volt;    

 do    

 {       Balance=Quotient%10;    

   volt[i++]=Balance;  

   }while(Quotient/=10);     //转换为char型  

   for(j=0;j<i;j++)     

 // if(volt[j]>9)    

  //   volt[j]=volt[i]+55;   

  //else      

 volt[j]+=48;         //字符串取反  

   for(k=0;k<i/2;k++)   

  {         char tmp;        

 tmp=volt[k];      

   volt[k]=volt[i-k-1];     

    volt[i-k-1]=tmp;    

}     return i;

}

 

 

 

unsigned int Int2String(unsigned int intnum,unsigned char *showstring)

{     unsigned int Quotient,Balance,i=0,j,k;   

    Quotient=intnum;        

 do   

  {    

   Balance=Quotient%10;   

    showstring[i++]=Balance;   

  }while(Quotient/=10);     //转换为char型    

for(j=0;j<i;j++)     

  if(showstring[j]>9)       

  showstring[j]=showstring[j]+55;   

  else showstring[j]+=48;         //字符串取反  

   for(k=0;k<i/2;k++)  

   {         char tmp;       

  tmp=showstring[k];        

 showstring[k]=showstring[i-k-1];       

  showstring[i-k-1]=tmp;  

   }     return i;

}

下面2个程序是德仪大学计划书里面的,搞不懂为什么大于9时候要+55