Quantcast
Channel: MSP 低功耗微控制器论坛 - 最近的话题
Viewing all articles
Browse latest Browse all 3634

在IAR编译好的程序在ccsv5报错,芯片是msp430g2533,应该怎么修改?谢谢

$
0
0

是读取ADC的采样信号,uart到pc,程序如下:


#include "msp430g2533.h"
#include"stdio.h"

void UART0_send_byte(unsigned char data) //发送一位
{
int j;
for( j=1000;j>0;j--);
UCA0TXBUF=data;
}

void UART0_send_str(char *s) //发送字符串
{
while(*s != '\0')
{
UART0_send_byte(*s++);
}
}
int main(void)
{
float num;
char buf[10];
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
ADC10CTL0 = ADC10ON; //开adc
ADC10CTL1 = INCH_0; //1通道
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**

while(1)
{
ADC10CTL0 |= ENC + ADC10SC; //开始转换
int j;
for( j=10000;j>0;j--);
num = (float)ADC10MEM*3.3/1024;
sprintf(buf,"V: %8.4f\n",num);
UART0_send_str(buf);
}


}


Viewing all articles
Browse latest Browse all 3634

Trending Articles