TI中文支持网
TI专业的中文技术问题搜集分享网站

求助:msp430F249串口发不出去数据

#include"msp430x24x.h"int addr;
char RXBUF_TEMP;
void DELAY(void)
{
int i;
for(i=1000;i>0;i–);
}

void Init(void)
{
P3SEL|=0XC0;
P3DIR=0XFF;
P3OUT=0;
P3REN=0XFF;
//UCA1CTL1=0x10;
UCA1CTL1|=UCSWRST;
UCA1CTL1 |= UCSSEL1;
UCA1CTL0=0;
UCA1BR0=0X03;
UCA1BR1=0X00;
UCA1MCTL=0X4A;
//UCA1TCTL=0X10;
// ME2|=0X30;
UCA1STAT =0x00;
UCA1CTL1&=~UCSWRST;
UC1IE|=UCA1TXIE+UCA1RXIE;
//UC1IE|=UCA1RXIE;
}
//发送一字节的数据
void UART1_PUTCHAR(int addr)
{
UCA1TXBUF=addr;
while((UCA1CTL1&0X01)==0);//等待该字节发送完}//接收一字节数据
char UART1_GETCHAR (void)
{
while((UC1IFG&UCA1RXIFG)==0);
return(UCA1RXBUF);
}void main (void)
{
//关闭看门狗
WDTCTL=WDTPW+WDTHOLD;
Init();
_EINT();
addr=1;
while(1)
{
UART1_PUTCHAR( addr);
UART1_GETCHAR();
RXBUF_TEMP=UCA1RXBUF;
if(RXBUF_TEMP!=0)
{
switch(RXBUF_TEMP)
{
case1:
// normal();
addr++;
break;
case2:
// error();
addr++;
break;
case3:
// alarm();
addr++;
break;
default:break;
}
}
}}

这是部分程序,求指导

wszqq:

请看430例程,按照比较标准规范的方式写程序。程序不是简单的罗列。

Lina Lian:

请参考MSP430Ware中相关例程并使用串口调试助手和示波器帮助调试,相关例程具体列表如下;

msp430x24x_uscia0_uart_01_19200.c USCI_A0, 19200 UART Echo ISR, DCO SMCLKmsp430x24x_uscia0_uart_01_9600.c USCI_A0, 9600 UART Echo ISR, DCO SMCLKmsp430x24x_uscia0_uart_04_9600.c USCI_A0, 9600 UART, SMCLK, LPM0, Echo with over-samplingmsp430x24x_uscia0_uart_05_9600.c USCI_A0, Ultra-Low Pwr UART 9600 Echo ISR, 32kHz ACLKmsp430x24x_uscia0_uart_06_9600.c USCI_A0, Ultra-Low Pwr UART 9600 String, 32kHz ACLKmsp430x24x_uscia0_uart_07_9600.c USCI_A0, Ultra-Low Pwr UART 9600 RX/TX, 32kHz ACLKmsp430x24x_uscia0_uart_08_9600.c USCI_A0, UART 9600 Full-Duplex Transceiver, 32kHz ACLK

MSP430Ware下载链接如下:

http://www.ti.com/tool/msp430ware

赞(0)
未经允许不得转载:TI中文支持网 » 求助:msp430F249串口发不出去数据
分享到: 更多 (0)