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
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;
}