最近我在做单片机和GSM模块连接的实验.主要是想运用AT指令实现短信的收发,现在还在起始阶段,遇到一些编程方面的问题,向各位请教。 关于发送短信的命令比方说,我先把GSM模块和电脑串口相连,我在超级终端(或串口调试助手)里输入命令: 输入: AT 输出:OK 输入:AT+CMGF=0 (这里把它设为PDU格式) 输出:OK 输入:AT+CMGS=21 输出: > 输入:0891683108200505F011000D91683119032069F000000006C8329BFD0E01 接着按CTRL+Z短信就被发送 我想把这些转换成C语言,写入单片机,然后把单片机和电脑串口相连, 我看到一些介绍说是要把输入的命令都改写成ASCII形式,我试着写了下面的程序 #include <REG52.H> #include <stdio.h> void main(void) {int i,j; SCON = 0x50; TMOD = 0x20; TH1 = 0xFA; TL1 = 0xFA; TI = 1; TR1 = 1; printf("41H54H2BH43H4DH47H46H3DH30H0DH"); //AT+CMGF=0 for(i=0;i<=10000;i++) for(j=0;j<=20;j++); printf("41H54H2BH43H4DH47H53H3DH32H31H0DH"); //AT+CMGS=21 for(i=0;i<=10000;i++) for(j=0;j<=20;j++); printf("30H38H39H31H36H38H33H31H30H38H32H30H30H35H30H35H46H30H31H31H30H30H30H44H39H31H36H38H33H31H31H39H30H33H32H30H36H39H46H30H30H30H30H30H30H30H30H36H43H38H33H32H39H42H46H44H30H45H30H31H0DH"); //0891683108200505F011000D91683119032069F000000006C8329BFD0E01 for(i=0;i<=10000;i++) for(j=0;j<=10000;j++); } 但是连接后gsm模块没有什么反应,希望能得到您的指点,我的程序哪里有问题,要发送短信需要怎样的步骤,谢谢你的指教
|