Arm gsm与LPC2148的接口

Arm gsm与LPC2148的接口,arm,gsm,at-command,uart,lpc,Arm,Gsm,At Command,Uart,Lpc,我正在尝试从我的ARM7 LPC2148板发送消息。我已将SIM900 GSM调制解调器连接到电路板的UART0。但是我没有收到手机上的信息!!我把打印语句放在这里和那里,这样我就知道系统在哪里,它在哪里卡住了。但它会打印所有信息。它说,即使我没有收到任何短信,也会发送消息。 代码如下: 主代码 gsm.c 将问题分为三个部分:配置和发送命令、接收正确的命令以及协同工作 将LPC2148板连接到PC,并使用PC终端程序观察您发送的命令。确保程序的各个部分工作正常。您是否在编译器中运行任何优化选项

我正在尝试从我的ARM7 LPC2148板发送消息。我已将SIM900 GSM调制解调器连接到电路板的UART0。但是我没有收到手机上的信息!!我把打印语句放在这里和那里,这样我就知道系统在哪里,它在哪里卡住了。但它会打印所有信息。它说,即使我没有收到任何短信,也会发送消息。 代码如下:

主代码

gsm.c


将问题分为三个部分:配置和发送命令、接收正确的命令以及协同工作

将LPC2148板连接到PC,并使用PC终端程序观察您发送的命令。确保程序的各个部分工作正常。您是否在编译器中运行任何优化选项?那肯定会弄乱你的延迟功能。使用内置计时器提供延迟,而不是循环。 确保使用正确的命令与GSM卡通话。如果可能,请将其连接到PC,如果其上没有RS-232收发器,请确保从逻辑电平转换为UART电平,或者转换到运行交互式终端的套件。确保您的命令确实会发送带有所选模块的SMS消息。 现在连接套件和模块。到现在为止,您应该知道哪些信号是实际输出,哪些是输入-RS-232对此可能非常混乱。大多数处理器UART标记为DTE TX==输出,RX==输入,我希望通信模块标记为DCE TX==输入,RX==输出,这意味着您将连接RXRX和TXTXT。如果它们都标记为DTE,则需要一根零调制解调器电缆来交换信号,或者在连接电路板时手动进行交换。
也许我遗漏了什么,但你没有在你提供的代码中发送任何SMSE。ATe0关闭回声,AT+CGMD删除消息,AT+CNMI配置新消息指示。要发送的消息为hello。我在msg[]中定义了。我还应该怎么做?我遗漏了什么/嗯-首先,您的代码中没有实际使用CGMS字符串的地方。其次,有两种方法可以使用AT+CGMS命令,文本格式或PDU格式。你似乎有一个邪恶的混合两者-我建议你读一个AT命令文件。第三,我很惊讶extern char foo[]=blah;即使是编译,我建议您打开/打开编译器上的警告;也许这只是为了IP/数据连接?我认为,除非调制解调器已连接到网络,否则即使是短信也无法工作。也许你需要在+CREG?要查看您是否已连接?@artlessnoise ATD拨打电话,您无需拨打电话即可发送短信。你说的对吗?这不是个坏主意。
#include "i2c.h"                      
#include "LPC214x.H"                                    // LPC2148 MPU Register
#include <stdio.h>
#include "gsm.h"
#include "lcd.h"
#include "buzzer.h"


extern int msgflag;                                                     
/* Main Program Start Here */
int main(void)
{  

   PINSEL0 = 0x00000000;        // Enable GPIO on all pins
PINSEL1 = 0x00000000;
PINSEL2 = 0x00000000;


  lcd_init();                                           // Initial LCD
  lcd_write_control(0x01);                              // Clear Display  (Clear Display,Set DD RAM Address=0) 
    goto_cursor(0x00);                                  // Set Cursor Line-1
    lcd_print("Accident Alert");                        // Display LCD Line-1  

                        // Display LCD Line-2
                                    // Display Delay

                                // Clear Display  (Clear Display,Set DD RAM Address=0) 
                        // Display LCD Line-1    
    goto_cursor(0x40);                                  // Set Cursor = Line-2
    lcd_print("System");                        // Display LCD Line-2
    delay1(100000000);


gsmperform();

  // Loop Print Message to LCD16 x 2 //
                                                // Loop Continue








sendmsg();
msgflag=0;
lcd_write_control(0x01);                            // Clear Display  (Clear Display,Set DD RAM Address=0) 
    goto_cursor(0x00);                                  // Set Cursor Line-1
    lcd_print("Message sent");                      // Display LCD Line-1  



}
#include<lpc214x.h>                                                  /*Header file*/
#include "gsm.h"                
#include "lcd.h"                                     //header file
extern unsigned char cmgf[]="AT+CMGF=1";                            //Text format in GSM modem
extern unsigned char cmgs[]="AT+CMGS=\"9xxxxxxxxx\"";               //Mobile number to which the msg is sent
extern unsigned char msg[]="hello";                                //secret code
extern unsigned char readall[]="AT+CMGR=\"REC UNREAD\"\r\n";


extern int blink;
unsigned char content[7];
void txu1(unsigned char data)                 //Transmit a byte of data through UART1
{
while(!(U1LSR & 0x20));                         // Wait until UART1 ready to send character  
    U1THR = data; 
}
unsigned char rxu1()
{
unsigned char p;
while ((U1LSR&0x01)!=1);
p=U1RBR;
return p;
}
unsigned char rxu0()
{
unsigned char p;
while ((U0LSR&0x01)!=1);
p=U0RBR;
return p;
}
void sendstring(unsigned char *p)            //Sends a string of data through UART1
{
while(1)
{
if(*p=='\0') break;
txu1(*p++);
}
}
void delaygsm()                           //delay function
{
int i,j;
for(i=0;i<60000;i++)
for(j=0;j<51;j++);
}
void delay2()                             //delay function
{
int i,j;
for(i=0;i<60000;i++)
for(j=0;j<200;j++);
}
unsigned char recuart1()             //recieves a byte from UART1
{
unsigned char p;
while ((U1LSR&0x01)!=1);
p=U1RBR;
return p;
}





void uart1_irq() __irq                    //ISR if anything is recieved in UART1, the same is transmitted through UART0
{
unsigned char p;
p=U1RBR;
if(p=='a')
{
sendmsg();
}
VICVectAddr=0;
}
void sendmsg(void)
{


sendstring(msg);


}
void initgsm()                               //Initialization of UART0,UART1 and ISR
{
U0LCR=0x83;
U0DLL=0x61;
U0DLM=0x00;
U0LCR=0x03;
U1LCR=0x83;
U1DLL=0x61;
U1DLM=0x00;
U1LCR=0x03;
U1IER=0x01;
U1FCR=0x07;
VICIntSelect&=0xffffff7f;
VICVectAddr2=(unsigned int)uart1_irq;
VICIntEnable|=0x00000080;
VICVectCntl2=0x20|7;  
}
void gsmperform(void)
{
lcd_write_control(0x01);                            // Clear Display  (Clear Display,Set DD RAM Address=0) 
    goto_cursor(0x00);                                  // Set Cursor Line-1
    lcd_print("begin gsm");                     // Display LCD Line-1  
PINSEL0|=0x00050005;
PINSEL1|=0x00000000;
PINSEL2|=0x00000000;
initgsm();
sendstring("ATe0\r\n");
delaygsm();
sendstring("AT+CMGD=1,4\r\n");
delaygsm();
sendstring("AT+CNMI=1,0,0,0\r\n");
delaygsm();
lcd_write_control(0x01);                            // Clear Display  (Clear Display,Set DD RAM Address=0) 
    goto_cursor(0x00);                                  // Set Cursor Line-1
    lcd_print("end gsm");                       // Display LCD Line-1  
}