Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Try Sending "AT\r"

Status
Not open for further replies.

RaminGsm

Newbie level 4
Joined
May 12, 2012
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,346
Thank you for your response
I send "AT\r" but I get uncorrect response from sim900.
my program in mikroc PRO Compiler is:
////////////////////////////////////////////////
#define LED1 PORTA.B0
#define LED2 PORTA.B1
#define Buzzer PORTB.B4

char receive;
void main()
{
int i=1;
TRISA.B0=0;
TRISA.B1=0;
TRISB.B4=0;
TRISC.B6=0;
TRISC.B7=1;

UART1_Init(9600);
delay_ms(400);
UART1_Write_Text("AT\r");
delay_ms(200);

while(i==1)
{ //First while loop
if(UART1_Data_Ready()==1)
{
receive = UART1_Read();
if((receive=='K')||(receive==0x4B)||(receive=='k')||(receive==75)||(receive=='O')) LED2=1;
else if(receive=='A') Buzzer=1;
else LED1=1;
}
}
}

After power up micro Buzzer and LED1 goes on.this indicate sim900 response is A and another character(perhaps T).
my schematic is in attachment pdf file:
 

Attachments

  • Sheet1.pdf
    103.3 KB · Views: 56

Try: "AT\n" ..? or possible "AT\r\n"

This code should do the same as yours with less clutter:
Code:
receive = UART1_Read();
switch( receive ){
  case 'O':
  case 'K':            
    LED2=1;
    break; 
  case 'A':  
    Buzzer=1;
    break;
  default:  
    LED1=1;
    break;
  }

You could try this too:
Code:
switch( (receive = UART1_Read()) ){
  case 'O': /* OK */
    if(  (receive=UART1_Read()) == 'K'  )
      LED2=1;
    break; 

  case 'A':  
    Buzzer=1;
    break;   

  default:  
    LED1=1;
    break;
  }
 
Last edited:

thank you
I correct my program as you say:
#define LED1 PORTA.B0
#define LED2 PORTA.B1
#define Buzzer PORTB.B4

char receive;
void main()
{
int i=1;
TRISA.B0=0;
TRISA.B1=0;
TRISB.B4=0;
TRISC.B6=0;
TRISC.B7=1;
UART1_Init(9600);
delay_ms(400);
UART1_Write_Text("AT\r\n");
delay_ms(200);

while(i==1)
{ //First while loop
if(UART1_Data_Ready()==1)
{
receive = UART1_Read();
switch( receive ){
case 'O':
case 'K':
LED2=1;
break;
case 'A':
case 'T':
Buzzer=1;
break;
default:
LED1=1;
break;
}
}
}
}

but when connect to sim900 Buzzer go on and indicate AT is response of sim900 module.
but why?
 

Your device echo everything you send back to you + its response. To turn it of use "ATE0" (or ATE1 to turn it on).

Btw, please edit your posts to use the "[ code] .. [/code]" tag.
 

-----Btw, please edit your posts to use the "[ code] .. [/code]" tag. -----??

---------- Post added at 23:05 ---------- Previous post was at 22:37 ----------

I edit program as :
#define LED1 PORTA.B0
#define LED2 PORTA.B1
#define Buzzer PORTB.B4

char receive;
void main()
{
int i=1;
TRISA.B0=0;
TRISA.B1=0;
TRISB.B4=0;
TRISC.B6=0;
TRISC.B7=1;
UART1_Init(9600);
delay_ms(400);
UART1_Write("A");
delay_ms(10);
UART1_Write("T");
delay_ms(10);
UART1_Write("E");
delay_ms(10);
UART1_Write("0");
delay_ms(10);
UART1_Write(0X0D);
UART1_Write(0X0A);
delay_ms(200);
UART1_Write_Text("AT\r\n");
delay_ms(200);

while(i==1)
{ //First while loop
if(UART1_Data_Ready()==1)
{
receive = UART1_Read();
switch( receive ){
case 'O':
case 'K':
LED2=1;
break;
case 'A':
case 'T':
Buzzer=1;
break;
case 'E':
case 'R':
{
Buzzer=1;
DELAY_MS(100);
Buzzer=0;
}
break;
default:
LED1=1;
break;
}
}
}
}

in this case LED1 goes on and micro doesn't get OK.
in correct response LED2 must be On.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top