#include<pic.h>
#include<pic16f91x.h>
#define uchar unsigned char
#define uint unsigned int
__CONFIG(0X3B31);
uchar qingping[]="\r\n";
uchar atset[]="AT\r\n";
//uchar textset[]="AT+CMGF=1\r\n";//格式为text
//uchar numset[]="AT+CMGS=18681950064\r\n";//目标手机号码
//uchar atd[]="ATD+8609173614405;\r\n";//拨打电话
//uchar ath[]="ATH\r\n";//挂断电话
uchar cstt[]="AT+CSTT\R\N"; //GPRS初始化
uchar ciicr[]="AT+CIICR\\r\n"; //激活移动场景
//uchar clport[]="AT+CLPORT="TCP","2022" //指定本地端口
uchar clport_1[]={'A','T','+','C','L','P','O','R','T','='};
uchar clport_2[]={'"','T','C','P','"',',','"','2','0','2','2','"'};
uchar cipstart_1[]={'A','T','+','C','I','P','S','T','A','R','T','='}; //连接SERVE
uchar cipstart_2[]={'"','T','C','P','"',',','"','1','1','7','.','3','3','.','7','9','.','0','"'};
uchar cipstart_3[]={'"','2','0','2','0','"'};
uchar cipsend[]="AT+CIPSEND"; //向SERVE发送数据
uchar gprsdata[]="313233343536373839301A0D\r\n"; //0x<1234567890+crtl-a>
//string clport="AT+CLPORT="TCP","2022"";
//string cipstart="AT+CIPSTART="TCP","117.33.90.0","2020"";
void init()//相关寄存器初始化
{
TXSTA=0X24;
RCSTA=0X90;
SPBRG=25;
TRISC=0XFF;
}
void delay(uint x)
{uint a,b;
for(a=x;a>0;a--)
for(b=110;b>0;b--);
}
void send(uchar data[],int length)
{
uint i;
for(i=0;i<length-1;i++)
{delay(10);
TXREG=data[i];
while(!TRMT);
delay(10);
}
}
void main()
{
init();
send(qingping,sizeof(qingping)); //清屏
delay(5000);
send(atset,sizeof(atset)); //AT
delay(5000);
send(atset,sizeof(atset)); //AT
delay(5000);
send(atset,sizeof(atset)); //AT
delay(5000);
send(atset,sizeof(atset)); //AT
delay(5000);
send(atset,sizeof(atset));//怕连接不上多发了几次at联机
delay(5000);
send(cstt,sizeof(cstt));
delay(5000);
send(ciicr,sizeof(ciicr));
delay(5000);
send(clport_1,sizeof(clport_1));
send(clport_2,sizeof(clport_2));
delay(5000);
send(cipstart_1,sizeof(cipstart_1));
send(cipstart_2,sizeof(cipstart_2));
send(cipstart_3,sizeof(cipstart_3));
delay(5000);
send(cipsend,sizeof(cipsend));
delay(2000);
send(gprsdata,sizeof(gprsdata));
delay(2000);
TXREG=0X36;
while(!TRMT);
while(1);
}
这个程序,不知怎么回事,始终变异不通过,IDE提示为:
Clean: Deleting intermediary and output files.
Clean: Deleted file "E:\pic project\SIM300-MIN-3.obj".
Clean: Deleted file "E:\pic project\SIM300-MIN-3.cce".
Clean: Done.
Executing: "d:\HT-PIC\BIN\PICC.EXE" -C -E"SIM300-MIN-3.cce" "SIM300-MIN-3.c" -O"SIM300-MIN-3.obj" -Zg9 -O -ASMLIST -Q -MPLAB -16F917
Warning[000] d:\HT-PIC\INCLUDE\pic16f91x.h 3 : #warning: Header file pic16f91x.h included directly. Use #include <htc.h> instead.
Executing: "d:\HT-PIC\BIN\PICC.EXE" -E"SIM300-MIN.lde" "E:\pic project\SIM300-MIN-3.obj" -M"SIM300-MIN.map" -O"SIM300-MIN.cof" -O"SIM300-MIN.hex" -Q -MPLAB -16F917
Error[000] : Can't find 0x7F words for psect rdata_0 in segment BANK0
Error[000] : Can't find 0x2 words for psect temp in segment COMBANK
Error[000] : Can't find 0x2 words (0x2 withtotal) for psect code_ptr in segment BANK0
BUILD FAILED: Thu Dec 16 09:12:59 2010
这是为什么呢?请各位高手帮忙解决一下,谢谢了。在线等。 |
|