写了好几天的程序了,但是怎么调试都不成功,大神能给解决下吗??刚自学这款单片机,是不是用串口通信啊??,,,
//******************************************************************************
#include <msp430.h>
#include <stdio.h>
const char string1[] = "ATD18669665328
";
//unsigned int i;
int a[8],i;
void Uart0Sends(char *s)
{
while (!(IFG2&UCA0TXIFG))
{
while(*s!=' ')
{
UCA0TXBUF=*s;
while((IFG2&UCA0TXIFG)==0); //查询发送是否结束
IFG2&=~UCA0TXIFG; //清除发送一标志位
s++;
}
}
}
void Init_uart0()
{
UCA0CTL0&=~UC7BIT;//字符长度为8
UCA0BR0=0x6D; //波特率为9600
/////////////------------------------------------------------------------
UCA0CTL1 |= UCSSEL_1; // CLK = ACLK
UCA0BR1 = 0x00; //
UCA0MCTL = UCBRS1 + UCBRS0; // Modulation UCBRSx = 3
UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
IE2 |= UCA0TXIE; // Enable USCI_A0 RX interrupt
////////////---------------------------------------------------------------
P1DIR = 0xFF; // All P1.x outputs
P1OUT = 0; // All P1.x reset
// All P2.x reset
P1SEL|=BIT1+BIT2; //将P1.1 P1.2设为第二功能
P1SEL2|=BIT1+BIT2;
}
void DelayNS(unsigned int dly)
{
unsigned int i;
for(;dly>0;dly--)
for(i=0;i<2000;i++);
}
int main(void)
{
WDTCTL = WDTPW + WDTHOLD;
BCSCTL1 = CALBC1_1MHZ;
DCOCTL = CALDCO_1MHZ;
Init_uart0();
_EINT();
}
//#pragma vector=USCIAB0RX_VECTOR
//__interrupt void usart0_rx(void)
//{
// while((IFG2&UCA0RXIFG )==0);
// //a=RXBUF0;
// //i++;
// i=UCA0RXBUF;
//// UCA0TXBUF=UCA0RXBUF;
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=USCIAB0TX_VECTOR
__interrupt void USCI0TX_ISR(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(USCIAB0TX_VECTOR))) USCI0TX_ISR (void)
#else
#error Compiler not supported!
#endif
{
{
Uart0Sends("AT
");
DelayNS(50);
Uart0Sends("AT+CMGF=1
");
DelayNS(50);
Uart0Sends("AT+CMGS="18669665328"
");
DelayNS(100);
Uart0Sends("DATATEST");
}
IE2 &= ~UCA0TXIE; // Disable USCI_A0 TX interrupt
}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
光看程序不好说呢
一周热门 更多>