在线看毛片网站电影-亚洲国产欧美日韩精品一区二区三区,国产欧美乱夫不卡无乱码,国产精品欧美久久久天天影视,精品一区二区三区视频在线观看,亚洲国产精品人成乱码天天看,日韩久久久一区,91精品国产91免费

<menu id="6qfwx"><li id="6qfwx"></li></menu>
    1. <menu id="6qfwx"><dl id="6qfwx"></dl></menu>

      <label id="6qfwx"><ol id="6qfwx"></ol></label><menu id="6qfwx"></menu><object id="6qfwx"><strike id="6qfwx"><noscript id="6qfwx"></noscript></strike></object>
        1. <center id="6qfwx"><dl id="6qfwx"></dl></center>

            新聞中心

            EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > MSP430G2553測(cè)試程序(溫度檢測(cè))

            MSP430G2553測(cè)試程序(溫度檢測(cè))

            作者: 時(shí)間:2016-11-28 來(lái)源:網(wǎng)絡(luò) 收藏
            //******************************************************************************

            //HW UART(J4)!!!!!! 特別注意,板子上J4有2個(gè)跳線(xiàn)要豎放,設(shè)為HW UART模式
            //ADC檢測(cè),并通過(guò)串口發(fā)送到PC
            //MSP430G2533 Demo - USCI_A0, 9600 UART Echo ISR, DCO SMCLK
            //http://jiwm.blog.163.com
            //Baud rate divider with 1MHz = 1MHz/9600 = ~104.2
            //ACLK = n/a, MCLK = SMCLK = CALxxx_1MHZ = 1MHz
            //
            //MSP430G2xx3
            //-----------------
            ///||XIN|-
            //| ||
            //--|RSTXOUT|-
            //||
            //|P1.2/UCA0TXD|------------>
            //|| 9600 - 8N1
            //|P1.1/UCA0RXD|<------------
            //
            // IAR Embedded Workbench Version: 5.40
            //******************************************************************************
            #include"msp430g2553.h"
            long temp;
            long IntDegF;
            long IntDegC;
            unsigned int i;
            void main(void)
            {
            WDTCTL = WDTPW + WDTHOLD;// Stop WDT
            ADC10CTL1 = INCH_10 + ADC10DIV_3;// Temp Sensor ADC10CLK/4
            ADC10CTL0 = SREF_1 + ADC10SHT_3 + REFON + ADC10ON + ADC10IE;//The ADC10OSC, generated internally,
            //is in the 5-MHz range, but varies with individual devices, supply voltage, and temperature. See the device-specific data sheet for the ADC10OSC specification.
            DCOCTL = 0x00;// Set DCO 1MHz
            BCSCTL1 = CALBC1_1MHZ;
            DCOCTL = CALDCO_1MHZ;
            P1SEL = BIT1 + BIT2 ;// P1.1 = RXD, P1.2=TXD
            P1SEL2 = BIT1 + BIT2 ;// P1.1 = RXD, P1.2=TXD
            UCA0CTL1 |= UCSSEL_2;// USCI clock source=SMCLK
            UCA0BR0 = 104;// 1MHz 9600Refer to Page 435 of X2xx Guide
            UCA0BR1 = 0;// 1MHz 9600
            UCA0MCTL = UCBRS0;// Modulation UCBRSx = 1
            UCA0CTL1 &= ~UCSWRST;// **Initialize USCI state machine**
            __enable_interrupt();// Enable interrupts.
            IE2 |= UCA0RXIE;// Enable USCI_A0 RX interrupt
            //__bis_SR_register(LPM0_bits + GIE);// Enter LPM0, interrupts enabled
            for(;;)
            {ADC10CTL0 |= ENC + ADC10SC;// Sampling and conversion start
            }


            }
            #pragma vector=USCIAB0RX_VECTOR//串口中斷
            __interrupt void USCI0RX_ISR(void)
            {
            if ((UCA0RXBUF == c)||(UCA0RXBUF == C))// C or c received?
            {
            //IE2 |= UCA0TXIE;// Enable USCI_A0 TX interrupt
            while (!(IFG2&UCA0TXIFG));// USCI_A0 TX buffer ready?
            {
            UCA0TXBUF=((IntDegC/10240)+48);//10位數(shù)

            }
            while (!(IFG2&UCA0TXIFG));// USCI_A0 TX buffer ready?
            {
            UCA0TXBUF=((IntDegC/1024)+48);//個(gè)位數(shù)

            }

            while (!(IFG2&UCA0TXIFG));// USCI_A0 TX buffer ready?
            {
            UCA0TXBUF=46;//.

            }
            while (!(IFG2&UCA0TXIFG));// USCI_A0 TX buffer ready?
            {
            UCA0TXBUF=((IntDegC*10/1024)+48);//小數(shù)

            }
            while (!(IFG2&UCA0TXIFG));// USCI_A0 TX buffer ready?
            {
            UCA0TXBUF=13;//換行

            }


            }
            else
            {

            本文引用地址:http://www.biyoush.com/article/201611/322871.htm


            //IE2 |= UCA0TXIE;// Enable USCI_A0 TX interrupt
            UCA0TXBUF = 13;//換行
            }
            }

            // ADC10 interrupt service routine
            #pragma vector=ADC10_VECTOR
            __interrupt void ADC10_ISR (void)
            {
            temp = ADC10MEM;
            //IntDegC = ((temp - 673) * 423) / 1024;//-278~144 ,精度降低了
            IntDegC = ((temp - 673) * 423); //改進(jìn)后的

            }



            評(píng)論


            技術(shù)專(zhuān)區(qū)

            關(guān)閉