hello, I am doing project on GSM but it not respond my controller(AT89S52).. This is my C code.. please any one help me out..
#include<reg51.h> #include<stdio.h> #include<stdlib.h> unsigned char Command_AT[]="AT\r\n"; unsigned char Command_CMGF[]="AT+CMGF=1\r\n"; unsigned char Command_CMGS[]="AT+CMGS =+917405738609\r\n"; unsigned char CtrlZ=0x1A; unsigned char msg02[]="TAMARO BABO RADE CHE"; #define display_port P0 //Data pins connected to port 2 on microcontroller sbit rs = P2^7; //RS pin connected to pin 2 of port 3 sbit rw = P2^6; // RW pin connected to pin 3 of port 3 sbit e = P2^5; //E pin connected to pin 4 of port 3 sbit obj = P1^0; sbit aud = P1^1; void msdelay(unsigned int time) // Function for creating delay in milliseconds. { unsigned i,j ; for(i=0;i<time;i++) for(j=0;j<1275;j++); } void GSM_modem(void) { msdelay(500); puts(Command_AT); msdelay(500); puts(Command_CMGF); msdelay(500); puts(Command_CMGS); puts(msg02); CtrlZ=0x1A; msdelay(500); while(!TI); TI = 0;SBUF = 0x1A; } void serialcommunication(void) { TMOD = 0x20; SCON = 0x50; TH1 = 0xFD; TL1 = 0xFD; TR1 = 1; TI = 1; } void lcd_cmd(unsigned char command) //Function to send command instruction to LCD { display_port = command; rs= 0; rw=0; e=1; msdelay(1); e=0; } void lcd_data(unsigned char disp_data) //Function to send display data to LCD { display_port = disp_data; rs= 1; rw=0; e=1; msdelay(1); e=0; } void lcd_init() //Function to prepare the LCD and get it ready { lcd_cmd(0x38); // for using 2 lines and 5X7 matrix of LCD msdelay(10); lcd_cmd(0x0F); // turn display ON, cursor blinking msdelay(10); lcd_cmd(0x01); //clear screen msdelay(10); lcd_cmd(0x81); // bring cursor to position 1 of line 1 msdelay(10); } void main() { unsigned char a[15]="*BHATT MAITREY*"; //string of 14 characters with a null terminator. int l=0; lcd_init(); serialcommunication(); GSM_modem(); while(a[l] != '\0') // searching the null terminator in the sentence { lcd_data(a[l]); l++; msdelay(50); } if(obj==1) { unsigned char a[15]="OBJECT AYI GAYO"; //string of 14 characters with a null terminator. int l=0; lcd_init(); serialcommunication(); GSM_modem(); while(a[l] != '\0') // searching the null terminator in the sentence { lcd_data(a[l]); l++; msdelay(50); } } aud=0; aud=1; if(aud==1) { unsigned char a[15]="AUDIOO AYI GAYO"; //string of 14 characters with a null terminator. int l=0; lcd_init(); serialcommunication(); GSM_modem(); while(a[l] != '\0') // searching the null terminator in the sentence { lcd_data(a[l]); l++; msdelay(50); } } }
View all questions in Keil forum