But i've coded GSM without using this ATE0 command. I used a delay after sending an AT command. It is working without any problems.
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 #include<reg52.h> #include<stdio.h> sbit a=P0^7; // LED Connected to this port unsigned char recive(); void transmit(unsigned char ); void init() { TMOD=0x20; TH1=0xFD; TL1=0xFD; SCON=0x50; TR1=1; TI=1; } void main() { unsigned char c[2]; init(); ES=1; EA=1; P0=0xFF; while(1) { transmit('A'); transmit('T'); transmit('\r'); c[0]=recive(); c[1]=recive(); if((c[0]=='O' && c[1]=='K') || (c[0]=='o' && c[1]=='k')) { a=0; // Led is On } } } void transmit(unsigned char c) { while(!TI); TI=0; SBUF=c; } unsigned char recive() { while(!RI); RI=0; return SBUF; }
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 main(){ . . . char GSM_OUTPUT[20]; transmit('A'); transmit('T'); transmit('\r'); while(1) { char c = recive(); switch(c){ case '0x0A': // if <LF> character received break; case '0x0D': // if <CR> character received GSM_OUTPUT[i] = '\x00'; if (strlen(GSM_OUTPUT) > 1){ // if 2nd <CR> received, then there will be some data if (strcmp(GSM_OUTPUT, "OK") == 0){ led = 0; i = 0; strcpy(GSM_OUTPUT, ""); } } break; default: if (i < 20){ GSM_OUTPUT[i] = c; i++; } else{ i = 0; } break; } }
Sir this is My Code:
#include<reg52.h>
#include<stdio.h>
sbit a=P0^7; // LED Connected to this port
unsigned char recive();
void transmit(unsigned char );
void init()
{
TMOD=0x20;
TH1=0xFD;
TL1=0xFD;
SCON=0x50;
TR1=1;
TI=1;
}
void main()
{
unsigned char c[2];
init();
ES=1;
EA=1;
P0=0xFF;
while(1)
{
transmit('A');
transmit('T');
transmit('\r');
c[0]=recive();
c[1]=recive();
if((c[0]=='O' && c[1]=='K') || (c[0]=='o' && c[1]=='k'))
{
a=0; // Led is On
}
}
}
void transmit(unsigned char c)
{
while(!TI);
TI=0;
SBUF=c;
}
unsigned char recive()
{
while(!RI);
RI=0;
return SBUF;
}
---------- Post added at 23:17 ---------- Previous post was at 21:46 ----------
Sir i appreciate your help. I have also downloaded Br@y ++ terminal but i am help less.It is very difficult to use as compared to hyperterminal .Because use with rx and tx pin and no other gnd to get connected with Pc.This works fine with Hypertermianl with gsm modem but unable to get response in br@y ++ terminal.
unsigned char c[6];
init();
ES=1;
EA=1;
P0=0xFF;
transmit('A');
transmit('T');
transmit('\r');
c[0]=recive();
c[1]=recive();
c[2]=recive();
c[3]=recive();
c[4]=recive();
c[5]=recive();
if( ( (c[2]=='O') && (c[3]=='K') ) || ( (c[2]=='o') && (c[3]=='k') ))
{
a=0; // Led is On
}
while(1)
{
}
void transmit(unsigned char c)
{
while(!TI);
TI=0;
SBUF=c;
}
unsigned char recive()
{
while(!RI);
RI=0;
return SBUF;
}
There is no problem with calling a delay. I did a project in the same manner. Calling a delay means to mask the ack bits comming from GSM.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?