怎么用51单片机读取sim900a接收的短信
4个回答
2015-07-30
展开全部
需要串口断接收才行
void Uart2InterruptReceive(void) interrupt 8
{
unsigned char tmp2;
//char i;
//num2=0;
IE2 &= (~ES2);//关闭串口2断//ES2 = 0;
if(S2CON & S2RI) //if(S2RI == 1)
{
S2CON &= (~S2RI);//S2RI = 0;
tmp2 = S2BUF;
//Uart1Send(tmp2);
rev_buf2[num2++]=tmp2;
if(num2>=80)
{
num2=0;
//Uart1Sends("GSM B "); 全试发送7/2320:03
}
}
else
{
S2CON &= (~S2TI);//S2TI = 0;
}
IE2 |= ES2;//ES2 = 1
}
void Uart2InterruptReceive(void) interrupt 8
{
unsigned char tmp2;
//char i;
//num2=0;
IE2 &= (~ES2);//关闭串口2断//ES2 = 0;
if(S2CON & S2RI) //if(S2RI == 1)
{
S2CON &= (~S2RI);//S2RI = 0;
tmp2 = S2BUF;
//Uart1Send(tmp2);
rev_buf2[num2++]=tmp2;
if(num2>=80)
{
num2=0;
//Uart1Sends("GSM B "); 全试发送7/2320:03
}
}
else
{
S2CON &= (~S2TI);//S2TI = 0;
}
IE2 |= ES2;//ES2 = 1
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询