Thanks for the interest shown...
Modem works fine and as expected when checked using hyper terminal.
To check whether i receive response from the modem i have written a small routine as follows:
The code simply initialize lcd and serial port (this is fine as i get expected behaviour from both). Then I try to send a simple "AT/r" to modem.
When microcontroller kit is connected with hyper terminal the code behaves as expected i.e. when we responding to microcontroller on HT as modem .
But when connected with microcontroller, (as seen in code)
step1: I send 'A' and i get it back from modem, and display it on LCD
setp2: I send 'T' and i get it back from modem, and display it on LCD
setp3: I send '\r' and i get it back from modem, and display it on LCD
setp4: I wait for the response to AT command i.e. <LF>OK<CR><LF>, but it seems MC stays there for infinite time waiting for the response and then after nothing is displayed on LCD
//------------------------------------------------------------
int main (void){
init_lcd();
init_serial ();
init_gsm_modem();
while(1);
}
//------------------------------------------------------------
//------------------------------------------------------------
void init_gsm_modem (void) {
char check;
lcd_command(0x80);
printlcd("AT\r");
check = gsm_command("AT"); //send at command
}
//------------------------------------------------------------
char gsm_command(char *CPtr){
char temp,temp1=0x42,temp2=0x42,temp3=0x42, temp4=0x42; //initialized with dummy value
char check=1;
char i=0xC0; // point to first location in LCD
while(*CPtr != '\0') {
sendchar(*CPtr);
temp = getchar();
lcd_command(i++);
lcd_data(temp); //display the received the echo of command sent
if (temp!=*CPtr){
check=0x00;
break;
}
CPtr++;
}
sendchar('\r'); //after AT send ‘\r’
temp = getchar();
lcd_command(i++);
lcd_data(temp);
while (!(U0LSR & 0x01)); //wait for the response expected <LF>OK<CR><LF>
temp1 = getchar();
while (!(U0LSR & 0x01));
temp2 = getchar();
while (!(U0LSR & 0x01));
temp3 = getchar();
while (!(U0LSR & 0x01));
temp4 = getchar();
lcd_command(0xC4); ;display what is received
lcd_data(temp1);
lcd_command(0xc5);
lcd_data(temp2);
lcd_command(0xc6);
lcd_data(temp3);
lcd_command(0xc7);
lcd_data(temp4);
return(check);
}