Hi, I am trying to send sms by using GM862-GPS, I am only connecting the TX pin right now. I took ATmega16 programming class 2-3 years ago, so I don’t remember much. Below is my code… It doesn’t send sms and I am not sure where am i doing wrong. I really appreciate any help or suggestions.
#include <mega16.h>
// Standard Input/Output functions
#include <stdio.h>
#include “delay.h”
// Declare your global variables here
char AT = {“AT”};
char BAUDRATE = {“AT+IPR=9600”};
char BND = {“AT#BND=3”};
char CMGF = {“AT+CMGF=1”};
char CMGS = {“AT+CMGS=+1xxxxxxxxxx”}; // phone number
char TEST = {“test”};
void sendmsg (char *s)
{
unsigned char curchar;
while (*s){
curchar = *(s++);
putchar(curchar);
}
}
void main(void)
{
.
.
.
// Port D initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=Out Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=0 State0=T
PORTD=0x00;
DDRD=0x02;
.
.
.
while (1)
{
// Place your code here
sendmsg(AT); //check for gm862 connection
putchar(0x0A);putchar(0x0D); //sends enter
delay_ms(300);
sendmsg(BAUDRATE); //set baud rate
putchar(0x0A);putchar(0x0D); //sends enter
delay_ms(300);
sendmsg(BND); //set the band to 3 for the USA
putchar(0x0A);putchar(0x0D); //sends enter
delay_ms(300);
sendmsg(CMGF); //ready to send sms
putchar(0x0A);putchar(0x0D); //sends enter
delay_ms(300);
sendmsg(CMGS); //receipant number
putchar(0x0A);putchar(0x0D); //sends enter
delay_ms(300);
sendmsg(TEST); //text
putchar(0x1A); //sends ctrl+z
delay_ms(300);
};
}