Bob Parihar
Member
ok now i decided that i will just check each command response
i read somewhere that gsm modem send OK for each successful retrieving of AT command
so i gust introduced serial interrupt for that and i am checking the response of "AT"
here is my code
#include"lcd.h"
unsigned char *command = "AT";
unsigned char CTRLZ = 0x1A, count;
unsigned char ar[5];
void serial_init(void);
void serial(unsigned char);
void puts(unsigned char *p );
void delay1(unsigned int);
void serial0() interrupt 4 {
if (TI==1) {
TI=0; //clear interrupt
}
else {
count=count+1;
ar[count]=SBUF;
RI=0; //clear interrupt
}
}
void main()
{
count=(-1);
init();
serial_init();
puts(command);
delay1(1000);
serial(CTRLZ);
print(&ar[0]);
while(1);
}
void serial_init(void)
{
TMOD=0x20; //timer 1, mode 2(8-bit autoreload) to set baud rate
TH1=0xFD; //-3 to TH1 for 9600 baud rate
SCON=0x50; // 8 bit txion, 1 start 1 stop bit, REN enable for both txfr and rxve
IE=0x90;
TR1=1; // start timer
}
void puts(char *p)
{
char *temp = p; /*temp pointer so that the actual pointer is not displaced */
while(*temp != 0x00)
{
serial(*temp);
temp++;
}
}
void serial(unsigned char x)
{
SBUF=x;
while(TI==0);
TI=0;
}
void delay1(unsigned int x)
{ int i,j;
for(i=0;i<x;i++)
for(j=0;j<1275;j++);
}
lcd.h header file contains this code:
#include<reg51.h>
sbit rs=P3^3;
sbit rw=P3^4;
sbit en=P3^5;
void dat(unsigned char);
void cmd(unsigned char);
void delay(unsigned int);
void print(unsigned char *);
void init();
void num(unsigned int);
void init()
{
cmd(0x38);
delay(100);
cmd(0x0E);
delay(100);
cmd(0x06);
delay(100);
cmd(0x01);
delay(100);
cmd(0x80);
}
void cmd(unsigned char x)
{
P2=x;
rs=0;
rw=0;
en=1;
delay(1);
en=0;
}
void dat(unsigned char y)
{
P2=y;
rs=1;
rw=0;
en=1;
delay(1);
en=0;
}
void delay(unsigned int z)
{
int j,i;
for(i=0;i<z;i++)
{
for(j=0;j<1275;j++);
}
}
void print(unsigned char *p)
{
while(*p!='\0')
{
dat(*p);
p++;
}
}
why iam not getting the "OK "on LCD?
i read somewhere that gsm modem send OK for each successful retrieving of AT command
so i gust introduced serial interrupt for that and i am checking the response of "AT"
here is my code
#include"lcd.h"
unsigned char *command = "AT";
unsigned char CTRLZ = 0x1A, count;
unsigned char ar[5];
void serial_init(void);
void serial(unsigned char);
void puts(unsigned char *p );
void delay1(unsigned int);
void serial0() interrupt 4 {
if (TI==1) {
TI=0; //clear interrupt
}
else {
count=count+1;
ar[count]=SBUF;
RI=0; //clear interrupt
}
}
void main()
{
count=(-1);
init();
serial_init();
puts(command);
delay1(1000);
serial(CTRLZ);
print(&ar[0]);
while(1);
}
void serial_init(void)
{
TMOD=0x20; //timer 1, mode 2(8-bit autoreload) to set baud rate
TH1=0xFD; //-3 to TH1 for 9600 baud rate
SCON=0x50; // 8 bit txion, 1 start 1 stop bit, REN enable for both txfr and rxve
IE=0x90;
TR1=1; // start timer
}
void puts(char *p)
{
char *temp = p; /*temp pointer so that the actual pointer is not displaced */
while(*temp != 0x00)
{
serial(*temp);
temp++;
}
}
void serial(unsigned char x)
{
SBUF=x;
while(TI==0);
TI=0;
}
void delay1(unsigned int x)
{ int i,j;
for(i=0;i<x;i++)
for(j=0;j<1275;j++);
}
lcd.h header file contains this code:
#include<reg51.h>
sbit rs=P3^3;
sbit rw=P3^4;
sbit en=P3^5;
void dat(unsigned char);
void cmd(unsigned char);
void delay(unsigned int);
void print(unsigned char *);
void init();
void num(unsigned int);
void init()
{
cmd(0x38);
delay(100);
cmd(0x0E);
delay(100);
cmd(0x06);
delay(100);
cmd(0x01);
delay(100);
cmd(0x80);
}
void cmd(unsigned char x)
{
P2=x;
rs=0;
rw=0;
en=1;
delay(1);
en=0;
}
void dat(unsigned char y)
{
P2=y;
rs=1;
rw=0;
en=1;
delay(1);
en=0;
}
void delay(unsigned int z)
{
int j,i;
for(i=0;i<z;i++)
{
for(j=0;j<1275;j++);
}
}
void print(unsigned char *p)
{
while(*p!='\0')
{
dat(*p);
p++;
}
}
why iam not getting the "OK "on LCD?