Interfacing Atmega 32 with GSM Mobile

Status
Not open for further replies.

dadda007

Newbie level 5
Joined
Nov 22, 2007
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,357
atmega sms

Hi all,

I am facing difficulty decoding an SMS from GSM with my micro-controller. After sending the appropriate AT commands i am trying to decode the PDU mode format of the SMS. In the following code i am reading the seventh location in the GSM mobile memory set and decoding the PDU to extract the message "Hi" , with the packed PDU code "C834" , i intend to put the value 0x0f on PORTA . However this idea doesn't seem to work .... cud someone help plz ????

Code:
#include<avr/io.h>
#include<util/delay.h>

void init_usart(void);	/* to initialse usart for transmitting */
void data_send(int);	/* to send the data */
int data_rxr(void);		/* to receive the data */

int main(void)

{

int c[13]={'A','T','+','C','P','M','S',0x3d,0x22,'M','E',0x22,0x0d};		/* to select memeory as the mobile equipment */
int c1[10]={'A','T','+','C','M','G','F',0x3d,0x30,0x0d};					/* select the format of sms as pdu format */
int d[2]={0xC8,0x34};
int ch[10]={'A','T','+','C','M','G','R',0x3d,0x37,0x0d},i,j[29],flag;		/* to read the 7 memory location */

DDRA=0x0f;
PORTA=0x00;

init_usart();

while(1)

{


for(i=0;i<13;i++)
data_send(c[i]);

_delay_ms(100);

for(i=0;i<10;i++)
data_send(c1[i]);

_delay_ms(100);


for(i=0;i<10;i++)
data_send(ch[i]);


for(i=0;i<29;i++)		/* receive the PDU string  which is 29 bytes long */
j[i]=data_rxr();


if((j[27]==d[0])&&(j[28]==d[1]))		/* check if the 28 and 29 location , ie the last 2 locations are equal to packed format of Hi or not */

{

flag=1;
break;

}

else
flag=0;


if(flag==1)				/* in case of true condition send 0x0f to PORTA */
PORTA=0x0f;

else
PORTA=0x00;

}

return 0;

}

void init_usart(void)

{

//UBRRH=0x00;
UBRRL=0x33;
//UCSRC=0x86;
UCSRB=0x18;
//UCSRA=0x00;

}

void data_send(int a)

{

while(!(UCSRA & (1<<UDRE)))

;

UDR=a;
PORTB=0x0f;

}



int data_rxr(void)

{

int a;

while(!(UCSRA & (1<<RXC)))

;

a=UDR;
PORTB=0x0f;

return a;

}
 

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…