430g2553编程入门小问题
时间:10-02
整理:3721RD
点击:
最近在自学430G2553launchpad,从TI例程里面摘取了ad转换和串口通讯的程序,想弄在一起,结果中断那块貌似出问题了,求大神解答。程序如下:
- #include <msp430.h>
- long temp;
- volatile unsigned int i;
- int main(void)
- {
- WDTCTL = WDTPW + WDTHOLD; // Stop WDT
-
- ADC10CTL0 = ADC10SHT_2 + ADC10ON + ADC10IE; // ADC10ON, interrupt enabled
- ADC10CTL1 = INCH_4; // input A1,IN P1.4
- ADC10AE0 |= 0x02; // PA.1 ADC option select
- // P1DIR |= 0x01; // Set P1.0 to output direction
- if (CALBC1_1MHZ==0xFF) // If calibration constant erased
- {
- while(1); // do not load, trap CPU!
- }
- DCOCTL = 0; // Select lowest DCOx and MODx settings
- BCSCTL1 = CALBC1_1MHZ; // Set DCO
- DCOCTL = CALDCO_1MHZ;
- P1SEL = BIT1 + BIT2 ; // P1.1 = RXD, P1.2=TXD
- P1SEL2 = BIT1 + BIT2 ; // P1.1 = RXD, P1.2=TXD
- UCA0CTL1 |= UCSSEL_2; // SMCLK
- UCA0BR0 = 104; // 1MHz 9600
- UCA0BR1 = 0; // 1MHz 9600
- UCA0MCTL = UCBRS0; // Modulation UCBRSx = 1
- UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
- IE2 |= UCA0RXIE; // Enable USCI_A0 RX interrupt
- IE2 |= UCA0TXIE; // Enable USCI_A0 TX interrupt
- for (;;)
- {
- ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start
- temp=ADC10MEM ;
-
- __bis_SR_register(LPM0_bits + GIE); // Enter LPM0, interrupts enabled
- }
- }
- // send AD character, confirm TX buffer is ready first
- #pragma vector=USCIAB0TX_VECTOR
- __interrupt void USCI0TX_ISR(void)
- {
- while (!(IFG2&UCA0TXIFG)); // USCI_A0 TX buffer ready?
- UCA0TXBUF = temp; // TX -> temp character
- ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start
- temp=ADC10MEM ;
- }
这个程序还是想做一个ad转换结果发送到电脑上面的功能
temp 是长整型 数据结构有问题