msp430ÖеÄADC12µÄͨµÀ10Á¬½Óµ½ÄÚ²¿Ä£Äâζȴ«¸ÐÆ÷ÉÏ£¬¿ÉÒÔ²âÁ¿msp430оƬζȣ¬²¢ÇÒ°ÑζÈÏÔʾÔÚ12864Òº¾§ÉÏ¡£
ÏÂÃæÊǵ÷ÊÔºóµÄ³ÌÐò¡£
#include
unsigned int long temp;
unsigned int long TemperF; //»ªÊÏζÈ
unsigned int long TemperC; //ÉãÊÏζÈ
#define uchar unsigned char
#define uint unsigned int
uchar a[]={\"»ªÊÏζȣº \"};
uchar b[]={\"ÉãÊÏζȣº \"};
//Ê¡ÂÔ12864²¿·ÖµÄ³ÌÐò
void main()
{
WDTCTL=WDTPW+WDTHOLD;
uint i;
initsys();//msp430 ϵͳ³õʼ»¯
PSB_0;//Òº¾§´®ÐÐ
init();//Òº¾§³õʼ»¯
ADC12CTL0=SHT0_8+REFON+ADC12ON;//ÄÚ²¿1.5v²Î¿¼µçѹ£¬´ò¿ªadc12£¬ÉèÖòÉÑù±£³Öʱ¼ä
ADC12CTL1=SHP;//ʹÓòÉÑù¶¨Ê±Æ÷
ADC12MCTL0=SREF_1+INCH_10;//²Î¿¼µçѹºÍͨµÀÑ¡Ôñ
ADC12IE=BIT0;//ADC12MEM0 ¾ßÓÐÖжÏÄÜÁ¦
ADC12CTL0|=ENC; //ÔÊÐíת»»
_EINT(); //¿ªÆôϵͳÖжÏ
while(1)
{
ADC12CTL0|=ADC12SC; //¿ªÆô²ÉÑù²¢ADת»»
TemperF=(temp-2519)*761;
TemperF=TemperF/4096; //¼ò»¯µÄ»ªÊÏζÈ
TemperC=(temp-2692)*423;
TemperC=TemperC/4096;//¼ò»¯µÄÉãÊÏζÈ
send_com(0x80);
for(i=0;i<10;i++)
send_data(a);
display((uint)TemperF);//12864ÏÔʾ»ªÊÏζÈ
send_com(0x90);
for(i=0;i<10;i++)
send_data(b);
display((uint)TemperC);//12864ÏÔʾÉãÊÏζÈ
}
}
#pragma vector=ADC12_VECTOR
__interrupt void ADC12ISR(void)
{
temp=ADC12MEM0;
}