Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

NEED HELP!! how to send sms via at commands via c programming using MSP430-eZRF2500..

Status
Not open for further replies.

Yusuf88

Newbie level 1
Joined
Jun 29, 2011
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,290
Hi

I am very new to this c programming. I would need c programming codes to send AT commands using using MSP430-eZRF2500.

MSP430 is the mirco controller im using to send sms.

thanks in advance.
 

engshahrul

Banned
Joined
Apr 27, 2009
Messages
330
Helped
97
Reputation
194
Reaction score
94
Trophy points
1,308
Location
Malaysia
Activity points
0
Do you know to use UART on that? If you know UART, you can refer to other microcontroller AT commands and convert it into MSP430. I have AT Command coding but I don't use MSP430.
 

like

Newbie level 5
Joined
Jun 13, 2011
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,417
I also have same problem as Yusuf88. I also need to do C programming to send sms from PC to Hp using GPRS Modem and AT Commands. How to do the coding? I have tried AT commands on hyperterminal to send SMS From PC to Hp. It can send and recieve sms . I am using IAR embedded workbench software.
 

seadolphine2000

Advanced Member level 3
Joined
Apr 12, 2005
Messages
881
Helped
122
Reputation
244
Reaction score
86
Trophy points
1,308
Activity points
7,374
Is your problem with the USART itself or with AT-Commands?
If it's with the USART, try to communicate with the computer first. Use the hyperterminal or any similar software and establish a communication between your controller and the computer.
If your problem is with the AT-Commands, I would recommend you to check the manual of the GPRS modem you are using since the syntax of the command can change from one vendor to another.

Hope this helps.
 

like

Newbie level 5
Joined
Jun 13, 2011
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,417
I am not sure on how to use UART on that. So can you pls guide me. Now i not sure what is the first step to send SMS from Computer to Handphone using GPRS modem and AT Commands. For my project i have done some coding. My project is on water level sensor The function of it is that one LED will turn on when 10cm the alert mode is active and 7 segment will display 10, and the two LED will turn on when 20cm the warning mode is active and 7 segment will display 20, the last emergency mode will active when the water level reached 30cm, the buzzer will turn on, and the 7 segment will display 30cm. Now Additional to this i want to add in SMS Function for Emergency level which is 30cm. Once the Water level reach 30cm it has to send sms to the higher authority to take action. But now i don't know how and where to add in the SMS Function inside my code. Pls help me asap.

Appendix A--Simple Tx/Rx source 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
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
#include "msp430x22x4.h"
#include "mrfi.h"
#define MRFI_RADIO_FAMILY1
int count=0;
void main(void)
{
  WDTCTL = WDTPW + WDTHOLD;
  BSP_Init();
  MRFI_Init();//initalize 6 pin wire connection between cc2500 & msp430
  MRFI_WakeUp();//wakes radio up
  MRFI_RxOn();//turn radio into receiving mode
  TACCTL0 = CCIE; 
  TACCR0 = 37500; 
  TACTL = TASSEL_2 + MC_1 + ID_3;
  P1DIR |= 0x03; // P1DIR = P1DIR | 0x03 Set P1.0, P1.1 to output direction
  P1OUT &= ~0x03;
  __bis_SR_register(GIE);
  TACCTL0 &= ~CCIE; 
  for (;;)
  {
    if(count>=0&&count<=15)
    {
      TACCR0 =37500; // Delay to allow Ref to settle
      TACCTL0 |= CCIE; // Compare-mode interrupt.
      ADC10CTL0 = SREF_0 + ADC10SHT_3 + REFON + ADC10ON + ADC10IE;//using Vcc and gnd for reference, 64 clks/sample, turn ADC on and enable interrupts
      ADC10CTL1 = INCH_0;
      ADC10AE0 |= 0x01;
      ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start
      __bis_SR_register(CPUOFF + GIE); // LPM0, ADC10_ISR will force exit
      if (ADC10MEM <0x50)
      {
        P1OUT |= 0x01; 
        P1OUT &= ~0x02;
        mrfiPacket_t packet;
        packet.frame[9]=' ';
        packet.frame[0]=8+20;
        packet.frame[9]='A';
        MRFI_Transmit(&packet,MRFI_TX_TYPE_FORCED);
      }
      else if (ADC10MEM > 0x50)
      {
        P1OUT |= 0x02; 
        P1OUT &= ~0x01;
        mrfiPacket_t packet;
        packet.frame[9]=' ';
        packet.frame[0]=8+20;
        packet.frame[9]='X';
        MRFI_Transmit(&packet,MRFI_TX_TYPE_FORCED);
      }
      ADC10CTL0 &= ~ENC; // Clear ENC to stop conversion
      ADC10CTL0 = 0;
    }
    else if(count>=16&&count<=30)
    {
      TACCR0 = 37500; // Delay to allow Ref to settle
      TACCTL0 |= CCIE; // Compare-mode interrupt.
      ADC10CTL0 = SREF_0 + ADC10SHT_3 + REFON + ADC10ON + ADC10IE;//using Vcc and gnd for reference, 64 clks/sample, turn ADC on and enable interrupts
      ADC10CTL1 = INCH_1;
      ADC10AE0 |= 0x02;
      ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start
      __bis_SR_register(CPUOFF + GIE); // LPM0, ADC10_ISR will force exit
      ADC10AE0 |= 0x02; // P2.1 ADC option select   
      if (ADC10MEM <0x50) 
      {
        P1OUT |= 0x01; 
        P1OUT &= ~0x02;
        mrfiPacket_t packet;
        packet.frame[9]=' ';
        packet.frame[0]=8+20;
        packet.frame[9]='W';
        MRFI_Transmit(&packet,MRFI_TX_TYPE_FORCED);
      }
      else if (ADC10MEM > 0x50)
      {
        P1OUT |= 0x02; 
        P1OUT &= ~0x01;
        mrfiPacket_t packet;
        packet.frame[9]=' ';
        packet.frame[0]=8+20;
        packet.frame[9]='Y';
        MRFI_Transmit(&packet,MRFI_TX_TYPE_FORCED);
      }
      ADC10CTL0 &= ~ENC; // Clear ENC to stop conversion
      ADC10CTL0 = 0;
    }
    else if(count>=31&&count<=45)
    {
      TACCR0 = 37500; // Delay to allow Ref to settle
      TACCTL0 |= CCIE; // Compare-mode interrupt.
      ADC10CTL0 = SREF_0 + ADC10SHT_3 + REFON + ADC10ON + ADC10IE;//using Vcc and gnd for reference, 64 clks/sample, turn ADC on and enable interrupts
      ADC10CTL1 = INCH_2;
      ADC10AE0 |= 0x04;
      ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start
      __bis_SR_register(CPUOFF + GIE); // LPM0, ADC10_ISR will force exit
      ADC10AE0 |= 0x04; // P2.2 ADC option select
      if (ADC10MEM <0x50) 
      {
        P1OUT |= 0x01; 
        P1OUT &= ~0x02;
        mrfiPacket_t packet;
        packet.frame[9]=' ';
        packet.frame[0]=8+20;
        packet.frame[9]='E';
        MRFI_Transmit(&packet,MRFI_TX_TYPE_FORCED);
      }
      else if (ADC10MEM > 0x50)
      {
        P1OUT |= 0x02; 
        P1OUT &= ~0x01;
        mrfiPacket_t packet;
        packet.frame[9]=' ';
        packet.frame[0]=8+20;
        packet.frame[9]='Z';
        MRFI_Transmit(&packet,MRFI_TX_TYPE_FORCED);
      }
      ADC10CTL0 &= ~ENC; // Clear ENC to stop conversion
      ADC10CTL0 = 0;
    }
  }
}
#pragma vector=ADC10_VECTOR
__interrupt void ADC10_ISR(void)
{
  __bic_SR_register_on_exit(CPUOFF); // Clear CPUOFF bit from 0(SR)
}
#pragma vector=TIMERA0_VECTOR 
__interrupt void Timer_A (void)
{
  if (count == 45)
  {
    count = 1;
  }
  else
  {
    count++;
  }
}
void MRFI_RxCompleteISR()
{
}



Appendix B—Water Level Sensor Detector

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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
#include "msp430x22x4.h"
#include "mrfi.h"
#define MRFI_RADIO_FAMILY1
#define P3_set_out P2DIR |=0x01;//set Pin 3 and pin 4 to output
#define P4_set_out P2DIR |=0x02;
#include <stdio.h>
 
 
 
#define a_set_out P2DIR |=0x04;//set P2.2 output direction 
#define b_set_out P2DIR |=0x08;//set P2.3 output direction 
#define c_set_out P2DIR |=0x10;//set P2.4 output direction 
#define d_set_out P4DIR |=0x08;//set P4.3 output direction 
#define e_set_out P4DIR |=0x10;//set P4.4 output direction 
#define f_set_out P4DIR |=0x20;//set P4.5 output direction 
#define g_set_out P4DIR |=0x40;//set P4.6 output direction 
 
 
#define a_on P2OUT |=0x04;
#define a_off P2OUT &=~0x04;
#define b_on P2OUT |=0x08;
#define b_off P2OUT &=~0x08;
#define c_on P2OUT |=0x10;
#define c_off P2OUT &=~0x10;
#define d_on P4OUT |=0x08;
#define d_off P4OUT &=~0x08;
#define e_on P4OUT |=0x10;
#define e_off P4OUT &=~0x10;
#define f_on P4OUT |=0x20;
#define f_off P4OUT &=~0x20;
#define g_on P4OUT |=0x40;
#define g_off P4OUT &=~0x40;
 
 
int num,num_1,num_2,r_1,count=0;
void main(void)
{
  WDTCTL = WDTPW + WDTHOLD;
  BSP_Init();
  P1REN|=0x04;
  P1IE|=0x04;
  MRFI_Init();//initalize 6 pin wire connection between cc2500 & msp430
  MRFI_WakeUp();//wakes radio up
  MRFI_RxOn();//turn radio into receiving mode
  TBCTL=TBSSEL_2+MC_1+ID_3;
  TBCCTL0=CCIE;
  TBCCR0=150;
  __bis_SR_register(LPM0_bits+GIE);
  P1DIR |= 0x03; // P1DIR = P1DIR | 0x03 Set P1.0, P1.1 to output direction
  P1OUT &= ~0x03;
  /*TBCTL=TBSSEL_2+MC_1+ID_3;
  TBCCTL0=CCIE;
  TBCCR0=150;*/
  __bis_SR_register(GIE);
  for(;;)
  {
  }
}
void MRFI_RxCompleteISR(void)
{
  mrfiPacket_t packet;
  MRFI_Receive(&packet);
  if(packet.frame[9]=='A')
  {
    P1OUT |= 0x01;
    P1OUT &=~0x02;
    P2OUT &=~0x03;
    P4DIR |=0x20;
    P4OUT |=0x20;
    
   
    
    a_set_out;//set P2.2->segment A as output pin
    b_set_out;//set P2.3->segment B as output pin
    c_set_out;//set P2.4->segment C as output pin
    d_set_out;//set P4.3->segment D as output pin
    e_set_out;//set P4.4->segment E as output pin
    f_set_out;//set P4.5->segment F as output pin
    g_set_out;//set P4.6->segment G as output pin
    
    num_1=(10/10);
    r_1=10%10;
    num_2=r_1/1;
    if(count>=0&&count<=4)
    {
      P2OUT &=~0x03;
      P2OUT |=0x01;
      num=num_1;
    }
    if(count>=5&&count<=10)
    {
      P2OUT &=~0x03;
      P2OUT |=0x02;
      num=num_2;
    }
    packet.frame[9]=' ';
 
    switch(num)
    {
    case 0:
      a_on;
      b_on;
      c_on;
      d_on;
      e_on;
      f_on;
      g_off;
      break;
    case 1:
      a_off;
      b_on;
      c_on;
      d_off;
      e_off;
      f_off;
      g_off;
      break;
    case 2:
      a_on;
      b_on;
      c_off;
      d_on;
      e_on;
      f_off;
      g_on;
      break;
    case 3:
      a_on;
      b_on;
      c_on;
      d_on;
      e_off;
      f_off;
      g_on;
      break;
    case 4:
      a_off;
      b_on;
      c_on;
      d_off;
      e_off;
      f_on;
      g_on;
      break;
    case 5:
      a_on;
      b_off;
      c_on;
      d_on;
      e_off;
      f_on;
      g_on;
      break;
 
    case 6:
      a_on;
      b_off;
      c_on;
      d_on;
      e_on;
      f_on;
      g_on;
      break;
    case 7:
      a_on;
      b_on;
      c_on;
      d_off;
      e_off;
      f_off;
      g_off;
      break;
    case 8:
      a_on;
      b_on;
      c_on;
      d_on;
      e_on;
      f_on;
      g_on;
      break;
    case 9:
      a_on;
      b_on;
      c_on;
      d_off;
      e_off;
      f_on;
      g_on;
      break;
    }
  
    
  }
  else if(packet.frame[9]=='W')
  {
    P1OUT &= ~0x01;
    P1OUT |= 0x02;
    P2OUT &=~0x03;
    P4DIR |=0x20;
    P4DIR |=0x40;
    P4OUT |=0x20;
    P4OUT |=0x40;
    
    
    a_set_out;//set P2.2->segment A as output pin
    b_set_out;//set P2.3->segment B as output pin
    c_set_out;//set P2.4->segment C as output pin
    d_set_out;//set P4.3->segment D as output pin
    e_set_out;//set P4.4->segment E as output pin
    f_set_out;//set P4.5->segment F as output pin
    g_set_out;//set P4.6->segment G as output pin
    
    
    num_1=(20/10);
    r_1=20%10;
    num_2=r_1/1;
    if(count>=0&&count<=4)
    {
      P2OUT &=~0x03;
      P2OUT |=0x01;
      num=num_1;
    }
    if(count>=5&&count<=10)
    {
      P2OUT &=~0x03;
      P2OUT |=0x02;
      num=num_2;
    }
    packet.frame[9]=' ';
 
    switch(num)
    {
    case 0:
      a_on;
      b_on;
      c_on;
      d_on;
      e_on;
      f_on;
      g_off;
      break;
    case 1:
      a_off;
      b_on;
      c_on;
      d_off;
      e_off;
      f_off;
      g_off;
      break;
    case 2:
      a_on;
      b_on;
      c_off;
      d_on;
      e_on;
      f_off;
      g_on;
      break;
    case 3:
      a_on;
      b_on;
      c_on;
      d_on;
      e_off;
      f_off;
      g_on;
      break;
    case 4:
      a_off;
      b_on;
      c_on;
      d_off;
      e_off;
      f_on;
      g_on;
      break;
    case 5:
      a_on;
      b_off;
      c_on;
      d_on;
      e_off;
      f_on;
      g_on;
      break;
 
    case 6:
      a_on;
      b_off;
      c_on;
      d_on;
      e_on;
      f_on;
      g_on;
      break;
    case 7:
      a_on;
      b_on;
      c_on;
      d_off;
      e_off;
      f_off;
      g_off;
      break;
    case 8:
      a_on;
      b_on;
      c_on;
      d_on;
      e_on;
      f_on;
      g_on;
      break;
    case 9:
      a_on;
      b_on;
      c_on;
      d_off;
      e_off;
      f_on;
      g_on;
      break;
      
     
    }
   
  }
 
  else if(packet.frame[9]=='E')
  {
    P1OUT |= 0x01;
    P1OUT |= 0x02;
    P4DIR |=0x20;
    P4DIR |=0x40;
    P4OUT |=0x20;
    P4OUT |=0x40;
    
    P3_set_out;
    P4_set_out;
    
    a_set_out;//set P2.2->segment A as output pin
    b_set_out;//set P2.3->segment B as output pin
    c_set_out;//set P2.4->segment C as output pin
    d_set_out;//set P4.3->segment D as output pin
    e_set_out;//set P4.4->segment E as output pin
    f_set_out;//set P4.5->segment F as output pin
    g_set_out;//set P4.6->segment G as output pin
    
    num_1=(30/10);
    r_1=30%10;
    num_2=r_1/1;
    if(count>=0&&count<=4)
    {
      P2OUT &=~0x03;
      P2OUT |=0x01;
      num=num_1;
    }
    if(count>=5&&count<=10)
    {
      P2OUT &=~0x03;
      P2OUT |=0x02;
      num=num_2;
    }
    packet.frame[9]=' ';
   
    switch(num)
    {
    case 0:
      a_on;
      b_on;
      c_on;
      d_on;
      e_on;
      f_on;
      g_off;
      break;
    case 1:
      a_off;
      b_on;
      c_on;
      d_off;
      e_off;
      f_off;
      g_off;
      break;
    case 2:
      a_on;
      b_on;
      c_off;
      d_on;
      e_on;
      f_off;
      g_on;
      break;
    case 3:
      a_on;
      b_on;
      c_on;
      d_on;
      e_off;
      f_off;
      g_on;
      break;
    case 4:
      a_off;
      b_on;
      c_on;
      d_off;
      e_off;
      f_on;
      g_on;
      break;
    case 5:
      a_on;
      b_off;
      c_on;
      d_on;
      e_off;
      f_on;
      g_on;
      break;
 
    case 6:
      a_on;
      b_off;
      c_on;
      d_on;
      e_on;
      f_on;
      g_on;
      break;
    case 7:
      a_on;
      b_on;
      c_on;
      d_off;
      e_off;
      f_off;
      g_off;
      break;
    case 8:
      a_on;
      b_on;
      c_on;
      d_on;
      e_on;
      f_on;
      g_on;
      break;
    case 9:
      a_on;
      b_on;
      c_on;
      d_off;
      e_off;
      f_on;
      g_on;
      break;
    }
    
  
 
 
  }
   
 
  else if(packet.frame[9]=='X')
  {
    //P1OUT |= 0x02;
    P1OUT &=~0x01;
    P4OUT &=~0x20;
    P4OUT &=~0x40;
    packet.frame[9]=' ';
  }
  else if(packet.frame[9]=='Y')
  {
    //P1OUT |= 0x02;
    P1OUT &=~0x01;
    P4OUT &=~0x20;
    P4OUT &=~0x40;
    packet.frame[9]=' ';
  }
  else if(packet.frame[9]=='Z')
  {
    //P1OUT |= 0x02;
    P1OUT &=~0x01;
    P4OUT &=~0x20;
    P4OUT &=~0x40;
    packet.frame[9]=' ';
  }
}
#pragma vector =PORT1_VECTOR 
__interrupt void Port_1(void)
{
  P1IFG&=~0x04;
  //BUZZER
}
#pragma vector=TIMERB0_VECTOR 
__interrupt void TB0_ISR(void)
{
  if (count == 10)
  { 
    count = 0;
  }
  else
  {
    count++;
  }
}

 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top