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.

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

Other Parts Discussed in Thread: MSP430G2533, TMP101, TMP100

是读取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);
}


}

  • 建议参考TI MSPWARE中例程,ADC 和UART都有现场的代码。 

    例外你现在碰到什么问题,请把问题描述清楚。

    yao wang5 说:

    是读取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--); // 建议参考我们的例程,判定采样标志位是否完成或利用中断来获取ADC采样值


    num = (float)ADC10MEM*3.3/1024;
    sprintf(buf,"V: %8.4f\n",num);
    UART0_send_str(buf);
    }


    }

  • 问题已经解决了,在库文件改成full就可以,谢谢回答,另外有没有,采集tmp101的温度,uart到pc的例程?
  • 这个TI MSP430没有这个例程,在TI M4 的tiva ware中有sensor lib 有TMP100例程,你可以参考。

    yao wang5 说:
    问题已经解决了,在库文件改成full就可以,谢谢回答,另外有没有,采集tmp101的温度,uart到pc的例程?

  • 没找到在哪里,能否给写个例程?

  • 在这里http://www.ti.com.cn/tool/cn/sw-tm4c-grl,安装tiva ware就有了

  • 能否帮忙把tmp100的例程发来?谢谢

x 出现错误。请重试或与管理员联系。