The Godfather talking
You think I am funny guy huh?
Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 08, 2016, 01:03:03 01:03


Login with username, password and session length


Pages: [1]
Print
Author Topic: receiving sms using GSM modem..??  (Read 2682 times)
0 Members and 1 Guest are viewing this topic.
deveshsamaiya
Newbie
*
 Muted
Offline Offline

Posts: 28

Thank You
-Given: 15
-Receive: 13


« on: August 28, 2009, 08:15:44 20:15 »

Hello everyone,

I am using a wave com GSM modem to receive/send sms. I wrote a program for ATmega32 that sends AT commands like AT, AT+CMGF=1, AT+CNMI=1,2,0,0,0 it sends sms it receive too but the problem is that when i work with PC hyper terminal all things are working well. when i connect gsm modem to UART of avr to receive any incoming sms. it receives but it skips some characters in between.

The problem basically is it skips some characters while receives a message.
Plz any one help me..
Code i used is like..
Code:
#include<avr/io.h>
#include<util/delay.h>
#include<avr/interrupt.h>
#include<compat/deprecated.h>
#include<lcd.h>
unsigned int i=0;
 unsigned char chunnu[160];
void uart_tx(unsigned char data)
{
  while(!(UCSRA & (1<<UDRE)));
  UDR=data;
}

SIGNAL(SIG_UART_RECV)
{
 
  chunnu[i++]=UDR;
  lcd_data(chunnu[i]);
  //i=i+1;
 
}
void uart_puts( char *s)
{
   while(*s)
   uart_tx(*s++);

}
int main(void)
{unsigned int j=0,k=0;
//unsigned char temp=0;
 DDRB=0xFF;
 DDRD=0xF0;
 PORTB=0x00;
 PORTD=0xFF;
 lcd_init();
 sei();
 UCSRA=0;
 UCSRB=(1<<TXEN)|(1<<RXEN)|(1<<RXCIE);
 UCSRC=1<<URSEL | 1<<UCSZ1 | 1<<UCSZ0;  // 8 data bit, a stop, none parity
 UBRRH=0;
 UBRRL=103; // for 9600 baud at 16MHz
 cbi(UCSRA,7);
 uart_puts("at");
 uart_tx(0x0D);   // enter after AT
 _delay_ms(2000);
 uart_puts("at+cmgf=1");
 uart_tx(0x0D);    // enter after AT+CMGF=1
 _delay_ms(1000);
 uart_puts("at+cnmi=1,2,0,0,0");  // Auto recive incoming sms
 uart_tx(0x0D);    // enter after AT+CNMI
 lcd_cmd(0x01);
 _delay_ms(1000);
 
 i=0;
 lcd_cmd(0x01);
 while(1==1)
 {
 }
   
   
 }
return 0;
}

Logged

embedded@iit
BORZUM
Newbie
*
 Muted
Offline Offline

Posts: 23

Thank You
-Given: 32
-Receive: 6


« Reply #1 on: August 28, 2009, 08:39:16 20:39 »

Hello deveshsamaiya,
I'm think the bromblem with skiping of the characters is mistake of incremeting value i before you sending data.

Try that:
Code:
SIGNAL(SIG_UART_RECV)
{
 
  chunnu[i]=UDR;
  lcd_data(chunnu[i]);
  i=i+1;                        // Why it were comment ???
  
}

Logged
deveshsamaiya
Newbie
*
 Muted
Offline Offline

Posts: 28

Thank You
-Given: 15
-Receive: 13


« Reply #2 on: August 28, 2009, 08:45:20 20:45 »

no i used the code below previously but the problem was same there also...then i modified that to i++ both the codes giving almost same output.
Code:
SIGNAL(SIG_UART_RECV)
{
 
  chunnu[i]=UDR;
  lcd_data(chunnu[i]);
  i=i+1;                        // Why it were comment ???
 
}
Logged

embedded@iit
BORZUM
Newbie
*
 Muted
Offline Offline

Posts: 23

Thank You
-Given: 32
-Receive: 6


« Reply #3 on: August 29, 2009, 07:58:09 07:58 »

Ok. Another problem can be in execution time of the function lcd_data(chunnu).
Maybe execution time of the function longer than time of receving next byte from UART ? Check it.
Logged
ali_asadzadeh
Junior Member
**
Offline Offline

Posts: 82

Thank You
-Given: 5
-Receive: 12


« Reply #4 on: August 31, 2009, 10:21:54 10:21 »

Note the maximum delay that can be produced by _delay_ms isabout 260ms!

you can get more delay in this way

void mydelay(long time)
{
       while(time--)
          _delay_ms(.96);
}


now use mydelay !
Logged
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC