我在一个函数中使能定时器3 同时在定时器3的中断服务函数中加入如下代码
u16 adcx;
float temp;
float temperate;
u8 *p1;
u8 *p;
p=mymalloc(SRAMIN,100); //申请100字节内存
p1=mymalloc(SRAMIN,100);
sim900a_send_cmd("AT+CIPCLOSE=1","CLOSE OK",100); //关闭连接
sim900a_send_cmd("AT+CIPSHUT","SHUT OK",100); //关闭移动场景
if(sim900a_send_cmd("AT+CGCLASS=\"B\"","OK",1000)==0)printf("AT+CGCLASS\n"); //设置GPRS移动台类别为B,支持包交换和数据交换
if(sim900a_send_cmd("AT+CGDCONT=1,\"IP\",\"CMNET\"","OK",1000)==0)printf("AT+CGDCONT\n");//设置PDP上下文,互联网接协议,接入点等信息
if(sim900a_send_cmd("AT+CGATT=1","OK",500)==0)printf("AT+CGATT\n"); //附着GPRS业务
if(sim900a_send_cmd("AT+CIPCSGP=1,\"CMNET\"","OK",500)==0)printf("AT+CIPCSGP\n"); //设置为GPRS连接模式
if(sim900a_send_cmd("AT+CIPHEAD=1","OK",500)==0)printf("AT+CIPHEAD\n"); //设置接收数据显示IP头(方便判断数据来源)
sprintf((char*)p,"AT+CIPSTART=\"%s\",\"%s\",\"%s\"","TCP","125.217.248.45","8086");
if(sim900a_send_cmd(p,"OK",500)==0)printf("OK");
adcx=Get_Adc_Average(ADC_CH_TEMP,10);
temp=(float)adcx*(3.3/4096);
temperate=temp;//保存温度传感器的电压值
temperate=(1.43-temperate)/0.0043+25;
allterm=temperate;
sprintf((char*)p1," %f ",temperate);
if(sim900a_send_cmd("AT+CIPSEND",">",500)==0) //发送数据
{
u2_printf("%s\r\n",p1);
delay_ms(10);
if(sim900a_send_cmd((u8*)0X1A,"SEND OK",1000)) return ;
}
希望能实现stm32内部温度传感器值的定时发送,但是很奇怪网络调试助手没有接受到信息,
同时用串口调试助手调试发现也没有收到信息,但是如果把这几行代码放在while循环里面就没有问题,求解决。。。。
|