单独打电话的程序可以运行,但是加上短信就不成功了,不知道为什么。求指导!
#include"msp430x14x.h"
#define uchar unsigned char
#define uint unsigned int
void Send1Char(uchar sendchar);
void PutString0(uchar *ptr);
void delay(uint z);
uchar *ATDPHONE="ATD15382342871;\r\n";
uchar *AT_CMGF="AT+CMGF=1\r\n";
uchar *AT_CMGS="AT+CMGS=";
uchar *NUMBER="15382342871";
uchar *ENTER="\r\n";
uchar *duanxin="haoma";
void main(void)
{
WDTCTL=WDTPW+WDTHOLD;
P3SEL|=0X30; //P3.4 3.5 TXD,RXD
ME1|=UTXE0+URXE0;
UCTL0|=CHAR;
UTCTL0|=SSEL0; //Aclk
UBR00=0X30; //波特率9600
UBR10=0X00;
UMCTL0=0X4A;
UCTL0 &=~SWRST;
IE1|=URXIE0;
_EINT();
while(1)
{
PutString0(AT_CMGF);
delay(10);
PutString0(AT_CMGS);
Send1Char(0x22) ;
PutString0(NUMBER);
Send1Char(0x22) ;
PutString0(ENTER);
delay(100);
PutString0(duanxin);
delay(100);
Send1Char(0x1A) ;
delay(50000);
}
}
void Send1Char(uchar sendchar)
{
U0TXBUF = sendchar;
while ((IFG1 & UTXIFG0)==0); //等待发送寄存器为空
IFG1&=~(UTXIFG0);
delay(10);
}
void PutString0(uchar *ptr)
{
while(*ptr != '\0')
{
Send1Char(*ptr++); // 发送数据
}
}
void delay(uint z)
{ uint i;
uchar j;
for(i=z;i>0;i--)
for(j=120;j>0;j--);
}
|