KVN1477
Junior Member level 3
Pic18F4550 & SIM300 (Monitor & control device using SMS). problem in reading "OK"
I have developed code to establish communication between SIM 300 GSM modem & PIC 18F4550 code is as follows...in Micro C pro.
i am sending AT command to Gsm modem & trying to DISPLAY "0K" ON lcd....
BUT PROGRAM STOPS DISPLAYING "Testing com..."
i am unable to understand weather "AT" is getting send to GSM modem and weather Modem is replaying with "OK"......
pls, help me to read & display "OK" from GSM modem..
// LCD module connections
sbit LCD_RS at LATB4_bit;
sbit LCD_EN at LATB5_bit;
sbit LCD_D4 at LATD4_bit;
sbit LCD_D5 at LATD5_bit;
sbit LCD_D6 at LATD6_bit;
sbit LCD_D7 at LATD7_bit;
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISD4_bit;
sbit LCD_D5_Direction at TRISD5_bit;
sbit LCD_D6_Direction at TRISD6_bit;
sbit LCD_D7_Direction at TRISD7_bit;
// End LCD module connections
char gsm_response[20];
void gsm_send_command(char *command)
{
while(*command)
{
uart1_write(*command++);
}
uart1_write(10);
uart1_write(13);
//Delay_ms(700);
}
void main()
{
PORTB = 0x00;
LATB = 0x00;
ADCON1 = 0x0F; // Configure AN pins as digital
CMCON=0; // comparator off
UART1_Init(9600); // Initialize UART module at 9600 bps
Delay_ms(200); // Wait for UART module to stabilize
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
Lcd_Out(1,1,"Smart Home..."); // Write text in first row
Delay_ms(2000);
Lcd_Cmd(_LCD_CLEAR); // Clear display
lcd_out(1,1,"Testing com...");
gsm_send_command("AT");//send AT to modem using subroutin
do
{
UART1_Read_Text(gsm_response,"OK ",2);// read response from Modem until OK received and save in variable gsm_response
}while (UART1_Data_Ready()==1);
Lcd_cmd(_Lcd_clear);
Lcd_out(1,1,gsm_response);// Display OK
delay_ms(5000);
}
I have developed code to establish communication between SIM 300 GSM modem & PIC 18F4550 code is as follows...in Micro C pro.
i am sending AT command to Gsm modem & trying to DISPLAY "0K" ON lcd....
BUT PROGRAM STOPS DISPLAYING "Testing com..."
i am unable to understand weather "AT" is getting send to GSM modem and weather Modem is replaying with "OK"......
pls, help me to read & display "OK" from GSM modem..
// LCD module connections
sbit LCD_RS at LATB4_bit;
sbit LCD_EN at LATB5_bit;
sbit LCD_D4 at LATD4_bit;
sbit LCD_D5 at LATD5_bit;
sbit LCD_D6 at LATD6_bit;
sbit LCD_D7 at LATD7_bit;
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISD4_bit;
sbit LCD_D5_Direction at TRISD5_bit;
sbit LCD_D6_Direction at TRISD6_bit;
sbit LCD_D7_Direction at TRISD7_bit;
// End LCD module connections
char gsm_response[20];
void gsm_send_command(char *command)
{
while(*command)
{
uart1_write(*command++);
}
uart1_write(10);
uart1_write(13);
//Delay_ms(700);
}
void main()
{
PORTB = 0x00;
LATB = 0x00;
ADCON1 = 0x0F; // Configure AN pins as digital
CMCON=0; // comparator off
UART1_Init(9600); // Initialize UART module at 9600 bps
Delay_ms(200); // Wait for UART module to stabilize
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
Lcd_Out(1,1,"Smart Home..."); // Write text in first row
Delay_ms(2000);
Lcd_Cmd(_LCD_CLEAR); // Clear display
lcd_out(1,1,"Testing com...");
gsm_send_command("AT");//send AT to modem using subroutin
do
{
UART1_Read_Text(gsm_response,"OK ",2);// read response from Modem until OK received and save in variable gsm_response
}while (UART1_Data_Ready()==1);
Lcd_cmd(_Lcd_clear);
Lcd_out(1,1,gsm_response);// Display OK
delay_ms(5000);
}
Last edited: