[ARM] sim900 gsm message not sending

Status
Not open for further replies.

ddnair

Junior Member level 1
Joined
Aug 25, 2014
Messages
15
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
128
Hai, I have some problem with my program ..ie using SIM900 gsm with lpc2148 microcontroller, the message is not sending...
But when I use SIM300 for the same program its working fine..
Can anyone help me with a solution.?
 

post schematic and code as asked in earlier post to help you better.
 

Gsm function code


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include "gsm.h"
#include "serial.h"
#include "lcd.h"
#include "string.h"
 
/******** sending AT commands to gsm modem through uart ********/
void send_command(char com[],unsigned int l)
{
unsigned int i;
    for ( i = 0 ; i < l ; i++)
        {
            uart1_tx(com[i]);
            //ms_delay(10);
        }
    uart1_tx(0x0D);
    uart1_tx(0x0D);
    uart1_tx(0x0A);
}
 
/************ send initialization commands to the GSM module ***********/
void send_init_cmd(void)
{
char chect_at[2] = "AT";
char at_flag[9] = "AT+CMGF=1";
    send_command(chect_at,2);
    ms_delay(100);
    send_command(at_flag,9);
    ms_delay(100);
}
 
void send_msg(unsigned char num)
{
char at_cmgs[21]="AT+CMGS=\"9986552281\"\n";        
    send_command(at_cmgs,21);      // send message send command to modem through uart
    terminate();
    ms_delay(100);
    if (num == 1)
    send_command("MOTOR SWITCHED ON",20);
    if (num == 0)
    send_command("MOTOR SWITCHED OFF",20);
    if(num == 2)
    send_command("Intruder Alert!!",20);
    ms_delay(100);
    terminate();
    ms_delay(100);
    uart1_tx(0X1A);     // ASCII value for Ctrl^z
    uart1_tx(0x0D);
    uart1_tx(0x0A);
    ms_delay(1000);
return;
} 
 
void terminate()
{
     uart1_tx(0x0D);
     uart1_tx(0x0D);
     uart1_tx(0x0A);
}

 
Last edited by a moderator:

Re: Gsm function code

code looks ok.but just try with some more delay then 100 ms and do check your rx,tx and gnd connections in hardware.
 

Re: Gsm function code

Where is the UART configuration code ? What baudrate are you using ?
 

Re: Gsm function code

9600 baudrate...

UART configuration code is given below:

Code:
void UART1_Init (void)			  /* Initialize Serial Interface       */
{   
	PINSEL0 |= 0x00050000;         /* Enable RxD1 and TxD1              */ 
	U1LCR = 0x00000083;         /* 8 bits, no Parity, 1 Stop bit     */
	U1DLL = 0x00000061;         /* 9600 Baud Rate @ 15MHz VPB Clock  */
	U1LCR = 0x00000003;        /* DLAB = 0                          */
}


unsigned char uart1_rx(void) 				 //Read character from Serial Port   
{                    
	while (!(U1LSR & 0x01));
return (U1RBR);
}	 

void uart1_tx(unsigned char tx)
{								    
	while(!(U1LSR & 0x20));
	//ms_delay(10);
	U1THR = tx;
} 

void uart1_txstr(unsigned char *str)
{
	while (*str != '\0')
		uart1_tx(*str++);
	uart1_tx('\n');
}
 

Re: Gsm function code

Will reply soon. I am learning LPC programming but will try to help you.
 

Re: Gsm function code

Hai friends,
Please help me on this topic. We have been discussing and still I didnt get any solution.
 

Re: Gsm function code

Hai friends,
Please help me on this topic. We have been discussing and still I didnt get any solution.

Is your sim 900 gsm working ok with the PC hyper terminal.Test your gsm 900 with PC with basic AT commands. Or you can test it with the your controller by sending AT and see its giving you reply OK.

Other possibility check you SIM card balance is sufficient to send a message.

What is your UART PIN YOU defined it wrong I guess.


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
***************************************************************************************
 
 
Title : Program to send a message from LPC2148 to mobile through GSM
 
 
***************************************************************************************
 
#define CR     0x0D
 
#include <LPC21xx.H>
 
#include <stdio.h>
 
 
 
void getstring(unsigned char *);
 
int getchar (void) /* Read character from Serial Port */
 
void status_ok(void);
 
void Serial_Init(void);
 
void delay(unsigned int n);
 
 
 
void main(void)
 
{
 
   unsigned int cnt=0x80,m;
 
   char xx;
 
   Serial_Init();
 
   delay(50);
 
 
 
   while(1)
 
   {
 
     printf("AT\r"); // AT COMMAND FOR INITIALING
 
     status_ok();
 
     printf("AT+IPR=9600\r"); // AT COMMAND FOR BAUD RATE
 
     status_ok();
 
 
 
     printf("AT+CMGR=2\r"); // Reading the message detail
 
// at Index 1 with phone number, data and time
 
     status_ok();
 
     delay(250);
 
    
 
     printf("ATD9790550124;\r");//AT COMMAND FOR CALL DIALING
 
     delay(250);
 
 
 
 
 
     status_ok();
 
    delay(500);
 
     delay(500);
 
     delay(500);
 
     delay(500);
 
     delay(500);
 
     delay(500);
 
    
 
     printf("ATH\r"); // AT COMMAND FOR CALL DISCONNECTING
 
     delay(250);
 
     status_ok();
 
     delay(500);
 
     delay(500);
 
 
 
     printf("ATDL\r"); // AT COMMAND FOR REDIALING
 
     delay(250);
 
     status_ok();
 
     delay(500);
 
     delay(500);
 
 
 
     printf("ATH\r"); // AT COMMAND FOR ANSWERING THE CALL
 
     delay(250);
 
     status_ok();
 
     delay(500);
 
     delay(500);
 
   }
 
}
 
 
 
void getstring(unsigned char *array)
 
{
 
   unsigned char temp=0, i=0;
 
   do
 
   {
 
       temp = getchar();
 
     *array++ = temp;
 
   }
 
   while((temp != '\r') && (temp != '\n'));
 
   *array = '\0';
 
  
 
}
 
 
 
 
 
 
 
int getchar (void) /* Read character from Serial Port */
 
{                  
 
 
 
while (!(U0LSR & 0x01));
 
return (U0RBR);
 
}
 
 
 
 
 
void status_ok(void)
 
{    
 
     getstring(y);
 
     while(!(strstr(y,"OK"))) getstring(y);
 
     pointr = strstr(y,"OK");
 
     lcd_cmd(0xc0);
 
     lcd_data(*pointr++);
 
     lcd_data(*pointr);
 
     delay(500);                                                
 
     lcd_cmd(0x01);
 
    
 
}
 
 
 
void Serial_Init(void)
 
{
 
   PINSEL0 |= 0X00000005; //Enable Txd0 and Rxd0
 
   U0LCR   = 0x00000083; //8-bit data, no parity, 1-stop bit
 
   U0DLL   = 0x00000061; //for Baud rate=9600,DLL=82
 
   U0LCR   = 0x00000003; //DLAB = 0;
 
}
 
 
 
void delay(unsigned int n)
 
{
 
   unsigned int i,j;
 
   for(i=0;i<n;i++)
 
   {
 
     for(j=0;j<12000;j++)
 
     {;}
 
   }
 
}

 
Last edited:

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…