Microcontroller › 8051 › 8051 keeps executing
- This topic has 13 replies, 3 voices, and was last updated 11 years, 6 months ago by
Anonymous.
-
AuthorPosts
-
July 25, 2013 at 3:00 pm #2554
Sandeep
ParticipantI am using 89V51RD2 . any program i dump in it for example a HELLO WORLD display on LCD. there is no while(1) in my program for infinite execution , but it keeps displaying it again and again . As i am doing a interface with SIM900 , i need to send a command only once , but because of this i am not able to proceed . for information : when i check dis in keil simulation it executes once and stops . but why is my hardware behaving like this ?
Someone pls help me know what is happening .
Thanks in advance
Sandeep
July 26, 2013 at 4:32 am #10204AJISH ALFRED
ParticipantHi Sandeep,
It happens just because of the absence of while(1) loop in your code.
Once your code done all the steps it simply won’t stop anmd remain idle, rather it redo executing from the first step. To avoid such situation people use while(1) or infinite loop at the end of their code. It helps in such a way that once the entire code is finished executing the controller enters into the infinite loop and remains there idle.
Just add
while(1);
at the end of your code and i hope it will solve the proble.
Also connect the Rx pin of the MCU to the Tx pin of the SIM300 only when it is necessary.
July 26, 2013 at 6:58 am #10208Sandeep
ParticipantThanks a lot for the suggestion . Now its executing only once . But if in case i have to send a data , i use a function
send_data(args);
while(1);
now my intention is to wait for another data to come from the other end . and now that there is a while(1); do you think it is possible.
I send AT only once
I have to wait for OK
in the waiting period how do stop my 8051 from re-executing
I hope u understood my problem
and thanks a lot in advance
July 31, 2013 at 5:10 am #10248AJISH ALFRED
ParticipantHi Sandeep,
Nice question.
You can use the while loop itself to wait till something happens.
For example you want to turn on an LED after the voltage at a pin say ‘P’ goes high. It can be done like the following;
//
//while ( P = = 0 ); // the code will continue looping here until the condition fails,
// means when the pin value becomes 1
led_on ();
//
//Hope you got the idea.
July 31, 2013 at 5:42 am #10249Sandeep
ParticipantThanks alot for the reply
I am stuck up in dis problem pls help me out with dis
the problem is :
TO SIM900:
PC-> Hyperterminal -> ATD9738XXXX18;<enter> : i get a call
8051 -> same command : not getting a call
have sent a carriage return after the command (0x0D)
used realterm to check if the data coming out of 8051 is right . it is perfect when i compared wat i manually send and the command coming out of the 8051.
SIM900 sends OK to the hyperterminal after the command
but it exactly sends <CR><LF>OK<CR><LF>
i didnt write a routine to recieve data in 8051. will that be a problem?
Next i did write a code to recieve and parallely as i recieve data i have to display it on the LCD(16×2)
but i get garbage values.
is my SIM900 not responding because i m ot accepting the OK or is there something else . I am seriously not able to understand where the problem
can u pls help me out with dis
Thanks in advance
Sandeep
August 1, 2013 at 5:02 am #10251AJISH ALFRED
ParticipantHi Sandeep,
I guess the max232 IC circuit between the 8051 and the SIM900 is working perfectly.
I also had the same problem, it was due to some power supply connection issue when connecting with the microcontroller board, the SIM900 will respond with AT commands but not able to make a call or send message.
Please post here the exact circuit you are using right now.
First try to fix this issue and then we will look into the LCD problem.
August 1, 2013 at 6:27 am #10252Sandeep
ParticipantThanks Ajish
There is no custom ciruitary i have buit
using 8051 development board
RS232 connection b/w 8051 board and sim900 board
data getting out of RS232 is perfectly fine as checked it in realterm.
now i am writing a small code to display data sent from hyperterminal on the LCD -> troubleshooting
how do u think power supply will be a problem?, 8051 and SIM900 working perfectly fine when used independently and the data sent to sim900 using 8051 and PC are exactly the same .
What do you think can be d problem?
Thanks
Sandeep
August 2, 2013 at 4:30 am #10260AJISH ALFRED
ParticipantHi Sandeep,
I’ve used a SIM900 based module, and by mistake I was using a 3.3V power adaptor. Still it was giving me response when I send AT comands !
But not able to make a call or send messages.
Since you are using two seperate power supply, the ground should be properly shorted together and the two power supply should not in anyway affect each other. Just make sure using a multimeter that you are getting 5V at the output of the regulator ICs in both your development board and the GSM module.
Post your LCD code, I’ll try to figure out if there is any bug in it.
August 2, 2013 at 4:35 am #10261Sandeep
ParticipantHi Ajish ,
U suspected that there may be a power supply problem
so I soldered two wires btw the module and now there is single power supply
and i also chkd with the multimeter ,its perfetly fine
i can send u the code :
send a dummy mail to my id sunny2791@gmail
i will immediately send the code to ur id
August 2, 2013 at 9:42 am #10262AJISH ALFRED
ParticipantHi Sandeep,
That’s good. Now you don’t have to worry about the hardware right!!
You can simply copy paste your code with your next post. I guess that would be far more better as you can get help or advise from other people in this forum.
August 8, 2013 at 10:32 am #10303Sandeep
ParticipantHi ajish thanks a lot for all ur replies
I found the bug
the Tx of 8051 was getting connected to Tx of SIM900 and same with Rx , it happened because i was using a male to male connector.
now that is resolved
data recieved was seen on LCD when i used
ch= SBUF;
str[count++]=ch; // used to store the data
lcd_data(str[count-1]); // directly showing wat ever i recievedNow wrote a code to display the stored data in str[] , which is not happening
code is:
char str[20];
void lcd_data(char data1){P0=data1;RS=1;RW=0;E=1;delay(10);E=0;}void serial_rx() interrupt 4{char ch;if(RI==1){ch= SBUF;if(ch==0X0D){carr=1;}if(ch==0X0A){linefd=1;}if(ch!=0x0D && ch!= 0x0A){str[count++]=ch;lcd_data(str[count-1]);}if(ch==0X0D && carr==1 ){str[count]=’