I am using external crystal of 16MHz.
In my code I have used UART Library which i found on this forum.
Here is my code
Code:
int main (void)
{
unsigned char s[80];
int n;
UART_init(); // in UART.c
sei(); // Global interrupt enable
///////////////////////////////////////////////////////////////////////////////////////////
//Make Echo OFF
UART_puts_P(PSTR("ATE0\r"));
// Getting Response from GSM Modem______Response should be OK
n = UART_gets(s, sizeof(s)-2);
s[strlen(s)-1] = 0; // drop the ending \r
///////////////////////////////////////////////////////////////////////////////////////////
//SENDING AT
UART_puts_P(PSTR("AT\r"));
// Getting Response from GSM Modem______Response should be OK
n = UART_gets(s, sizeof(s)-2);
s[strlen(s)-1] = 0; // drop the ending \r
///////////////////////////////////////////////////////////////////////////////////////////
//SENDING AT+CMGF
UART_puts_P(PSTR("AT+CMGF=1\r"));
// Getting Response from GSM Modem______Response should be OK
n = UART_gets(s, sizeof(s)-2);
s[strlen(s)-1] = 0; // drop the ending \r
///////////////////////////////////////////////////////////////////////////////////////////
//SENDING AT+CMGS
UART_puts_P(PSTR("AT+CMGS=\""));
UART_puts_P(PSTR("91my_no")); //Country code
UART_puts_P(PSTR("\"\r"));
UART_puts_P(PSTR("Hi\r"));
UART_puts_P(PSTR("0x1A")); //Sending Ctrl+Z
// Getting Response from GSM Modem______Response should be +CMGS= some ID and then OK
n = UART_gets(s, sizeof(s)-2);
s[strlen(s)-1] = 0; // drop the ending \r
_delay_ms(150);
return 0;
}
|