#include "msp430G2553.h"
#include "stdio.h"
#define LED_1 (0x01) // P1.0 = LED1 输出
#define LED_2 (0x40) // P1.6 = LED2 输出
char a;
void Init_uart0()
{
UCA0CTL1|=UCSWRST;
P1SEL|=BIT1+BIT2; //将P1.1 P1.2设为第二功能
P1SEL2|=BIT1+BIT2;
P1DIR |= BIT2; //P1.2 UART_TX
P1DIR &=~BIT1; //P1.2 UART_RX
UCA0CTL0&=~UC7BIT;//字符长度为8
UCA0CTL1|=UCSSEL_2;//选择系统时钟
UCA0BR0=0x68; //波特率为9600
UCA0BR1=0;
UCA0MCTL=0X40;//UCA0MCTL=UCBRS0;
UCA0CTL1&=~UCSWRST;
P1DIR = LED_1 + LED_2;
P1OUT = 0x00;
IE2|=UCA0RXIE;//开接收使能
}
void Uart0Sends(char *s)
{
while(*s!='\0')
{
UCA0TXBUF=*s;
本内容试读结束,登录后可阅读更多
下载后可阅读完整内容,剩余2页未读,立即下载