GPRS模块发送信息代码
for(;i>0;i--)
{
for(j=0;j<125;j++)
{;}
}
}
//---延时US------------------------------
void dmsec (unsigned int count)
{
unsigned int i;
while (count)
{
i =300;
while (i>0) i--;
count--;
}
}
/************************************************************************************************
********************************系统初始化*******************************************************
************************************************************************************************/
void sys_init(void)//UART TIMER0初始化
{
TH0 = 0xB8;
TL0 = 0x00; //20ms的时钟基准
//串口中断
TI=0;
RI=0;
SCON=0x50; //选用方式1
TMOD=0x20;
TMOD = (TMOD & 0xf0) | 1;//MODE 1
TH1=0xfd; //波特率为9600
TL1=0xfd;
PCON=0x00; //倍频0x80
IE = 0xb0; // EA XX ET2 ES ET0 EX0 ET1 EX1
TR1=1; //enable TIMER1
ES=1; //开串口开断
TR0=1; //串口接收中断
ET0=0; //T0 中断
ET1=0; // T1 中断
EA=1;
timer_1S_cnt=0;
}
/******************************************************************************************************************
///////////////////函数void GSM_INIT(void);实现功能:初始化模块///////////////////////////////
******************************************************************************************************************/
void GSM_init(void)
{
Delay_ms(5000); //
Delay_ms(5000);
Delay_ms(5000); //等待模块启动并联网
while(1)
{
clear_SystemBuf();
sendstring(AT);
Delay_ms(1000);
if((SystemBuf[5]==O)&&(SystemBuf[6]==K))//判断是否模块初始化成功,成功的话模块会回复"OK"给单片机
{//如果单片机没有收到OK,就继续发送初始化指令/
LED_S0=~LED_S0;break; //P1.7指示灯亮
}
Delay_ms(1000);
}
sendstring(ATZ);//初始化
Delay_ms(1000);
sendstring(AT_IPR);//9600
Delay_ms(1000);
sendstring(ATE0V1);//关闭回显设置DCE为OK方式
Delay_ms(1000);
while(1)
{
clear_SystemBuf();
sendstring(AT_CPIN);//查询SIM卡状态
Delay_ms(1000);
// MOUDULE -> MCU
//[0D][0A]
//+CPIN: READY[0D][0A]
//[0D][0A]
//OK[0D][0A]
if((SystemBuf[18]==O)&&(SystemBuf[19]==K))
{
LED_S1=~LED_S1;break; //P1.6指示灯亮
}
Delay_ms(1000);//READY??
LED_S7=~LED_S7;
}
//GPRS初始化
//其他采用模块默认设置
sendstring(AT_CDSNORIP);Delay_ms(1000); //选择域名还是IP方式,这里我们采用IP模式
sendstring(AT_CIPHEAD); Delay_ms(1000); //接收的数据带+IPD字符串
}
/****************************************************************************************************************/
///////////////////////////////////////void clear_SystemBuf();清除串口接收缓冲区/////////////////////////////////
/****************************************************************************************************************/
void clear_SystemBuf()
{
for(Rx=0;Rx
SystemBuf[Rx]=0x00;
}
Rx=0;
}
/******************************************************************************************************************
///////////////////函数void receive(void) interrupt 4 using 1;实现功能:通过串口接收数据////////////////////////////
******************************************************************************************************************/
void receive(void) interrupt 4 using 1
{
if(RI)
{
if(Rx
SystemBuf[Rx]=SBUF;
Rx++;
}
RI=0;
}
}
GPRS模块发送信 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)