SparkFun Forums 

Where electronics enthusiasts find answers.

Your source for all things Atmel.
By apuvas
#53913
hi all i am trying to send sms by modem using usart commmunication by ATmega8.the
program when tested through hyperterminal seems to look correct but when connected
to modem it does not send sms..

please help and tell me the required corrections
REPLY ME AT
deep_mishra2107@yahoo.co.in
or
bvasal@gmail.com


THE CODE IS BELOW

#include <stdio.h>
#include <avr/io.h>
#include <util/delay.h>
#include <string.h>
static int put_char(char c, FILE *stream);
static FILE mystdout = FDEV_SETUP_STREAM(put_char, NULL, _FDEV_SETUP_WRITE);
void init_uart(void)
{
UCSRB = (1<<RXEN) | (1<<TXEN);
// enable receive complete interrupt
UCSRB |= (1<<RXCIE);
//UCSRC = (1<<URSEL) | (3<<UCSZ0); // 8 bit, 1 stop bit, no parity
UCSRC = ( 1<<URSEL | 1<<UCSZ1 | 1<<UCSZ0 );
UBRRH = 0;
UBRRL = 12; //9600 baud at 2 MHz
}
static int put_char(char c, FILE *stream)
{
loop_until_bit_is_set(UCSRA, UDRE); // wait for UDR to be clear
UDR = c; //send the character
return 0;
}
int main(void)
{
init_uart(); // Initialize the uart
stdout = &mystdout; //set the output stream
printf("as");//this string is send because initial strings are transmitted twice..
_delay_ms(300);
printf("AT"); //AT
putchar(0x0D); //Enter
//putchar(0x0A); //Line feed
_delay_ms(300);
printf("AT+CMGF=1");
putchar(0x0D);
// putchar(0x0A);
_delay_ms(300);
printf("AT+CMGS=9826749352");
putchar(0x0D);
// putchar(0x0A);
_delay_ms(300);
printf("hi this is deepak %c",0X1A); // 0X1A for ctrlz
_delay_ms(1000);

return 0;
}
By AdiCPT
#53949
I have played a bit with GSM modules, and from what I can see you are missing some initialization strings, and the number should be in international format e.g. +…, to my understanding most mobiles do this for you transparently, please correct me if I am wrong.

The initialization I use is

ATZ
delay
ATZ
delay

ATE0 wait for OK to return
ATI wait for OK to return

AT+CMEE=1 wait for OK to return

AT+CLIP=1 wait for OT to return
AT+CSMS=1 wait for OK to return
AT+COPS=3,0 wait for OK to return

Check and enter PIN here if you are planning on using SIM PIN protection.

AT+CMGF=1 wait for OK to return and an additional bit to ensure a network lock

Then to send SMS

AT+CMGS="+1234567890" wait for > to return
message concat char 26 and wait for +CMGS: to return

Have you tried hooking the modem up to a PC and using a terminal application like Hyper term to see any errors/NAK’s being reported.

PS! I do not reply to email addresses otherwise the solution will not benifit other people, also if I am wrong nobody can correct me.
By apuvas
#53963
hi my commands work fine for sending sms..i have checked it in hyperterminal.but my modem does not reply...
i dont know whether interrupts are required .please help
By n1ist
#54022
Have you tried connecting the Atmega8 to the PC (with the appropriate level shifter) to see whether it is sending correctly?

As for interrupts, you are polling the UART RX, so you should not enable the receive interrupt (RXCIE).

Are the fuses set correctly to enable the external oscillator? The internal RC oscillator can give you either 8MHz or 1MHz (and may not be accurate enough for serial communications).

/mike
By apuvas
#54102
i am still having problem..should i use 32 bit microcontroller???????is there any difference b/w usart communication by 8,16,32 bit microcontrollers
Last edited by apuvas on Thu Aug 28, 2008 2:38 am, edited 1 time in total.
By apuvas
#54441
hi i have tried to communicate modem with microcontroller ,but there still exist some flaws and modem is not sending sms..
By stevech
#54478
apuvas wrote:i am still having problem..should i use 32 bit microcontroller???????is there any difference b/w usart communication by 8,16,32 bit microcontrollers

No and No.