We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
hallo i'm trying to one project my own interest using p89v51RD2 muc i have one problem my project is GSm based so my code working well on keil while debugging, but when burning on chip it's not working , actual problem is one receive and transmit complete after clear buffer and i value then next receive data is "miss match" then after clear i value and buffer then next receive data is "match" then one transmission complete next receive data will be "miss match" i'm using flash magic for burn in chip. that's my problem
any body help me please .....!
by Raja Durai.E
Do you mean Simulating ?
ie, with the code running entirely on your PC - not on external hardware?
"actual problem is one receive and transmit complete after clear buffer and i value then next receive data is "miss match" then after clear i value and buffer then next receive data is "match" then one transmission complete next receive data will be "miss match" i'm using flash magic for burn in chip. that's my problem"
Sorry - I can't make any sense of that!
yes Simulating my code is well working but while loading on chip is not working. this my code using interrupt 4, that's only ISR interrupt code here that's problem
void ISR_SC(void)interrupt 4 { IE=0x00; if(RI==1) { buffer[i]=SBUF; RI=0; f=buffer[i]; ++i; if(f=='#') { for(i=13,j=0;i<23;i++,j++) { if(admin[j]!=buffer[i]) break; } if(j==10) { switch(buffer[50]) { case'A':add(); break; case'C':chpwd(); break; case'S':shop_addr(); break; default:send_sms4(); break; } } else { for(i=50,j=0;i<61;i++,j++) { if(RADMN[j]!=buffer[i]) break; } if(j==11) { if(n==1) { for(i=13,j=0;i<23;i++,j++) { if(admin[j]!=buffer[i]) break; } } else { for(i=13,j=0;i<23;i++,j++) { admin[j]=buffer[i]; } n=1; send_sms5(); green=1; delay(500); green=0; } } else { red=1; delay(500); red=0; } } i=0; j=0; y=y+1; buffer_clr(); del_sms(); } } IE=0x90; }
That's a very big ISR for a small processor.
And do you have global variables named "f", "i", "j", "n", "y"? Is that really good variable names to pollute the global name space with?
And your ISR even has delays? Most people consider ISR code to be time critical, because they want the processor ready to handle the next hardware event - you seem to have all the time in the world to spend in your ISR. Why don't you leave something to do for your main loop?
Another thing - ever heard about finite state machines? It's possible to process just a single character each iteration based on current state and received character. Just remember that a the code mustn't tell wich specific character of a password that was wrong - then it's so easy to iterate to character by character until the unknown password has been found. The failure shouldn't be reported until the full "pin code" has been received of there is a termination character (like return) received.
No kidding!!
"And your ISR even has delays?"
Oh dear!
"Most people consider ISR code to be time critical, because they want the processor ready to handle the next hardware event"
In the simulator, the serial IO is buffered by the PC & Windows; on the real chip, it is not!
A lot of hard coded numbers in there, maybe you want to reflect a little harder about what you are parsing, and how to make it recoverable, and add some comments.
... and sort the indentation out!!
sort the indentation out!! probably = get rid of tabs, use spaces only
Thank You all reply for me But my problem is first receive char stored buffer then compared with already stored(globally) value if it's true then do some process like number store function(add();),password change function(chpwd();)etc, it's all done perfect, then "acknowledgment" get from micro controller(p89v51RD2) through sms ( send_sms5();,send_sms1();,ect,,) also done next another process again receive char it's not compare that means miss match( glowing red LED),then do again this process (receive char) it's working done then get "acknowledgment" through sms is done, then another process again receive char it's not compare that means miss match( glowing red LED), it's repeat again again one "acknowledgment" get from mc next receive char miss match,
" if "acknowledgment" through sms replaced only LED glowing for acknowledgment it's all working fine, so any transmit from mc then receive char were store in buffer that's problem, how can rectify that ...?
Thank You for reply me But my problem is first receive char stored buffer then compared with already stored(globally) value if it's true then do some process like number store function(add();),password change function(chpwd();)etc, it's all done perfect, then "acknowledgment" get from micro controller(p89v51RD2) through sms ( send_sms5();,send_sms1();,ect,,) also done next another process again receive char it's not compare that means miss match( glowing red LED),then do again this process (receive char) it's working done then get "acknowledgment" through sms is done, then another process again receive char it's not compare that means miss match( glowing red LED), it's repeat again again one "acknowledgment" get from mc next receive char miss match,
Thank You All reply for me But my problem is first receive char stored buffer then compared with already stored(globally) value if it's true then do some process like number store function(add();),password change function(chpwd();)etc, it's all done perfect, then "acknowledgment" get from micro controller(p89v51RD2) through sms ( send_sms5();,send_sms1();,ect,,) also done next another process again receive char it's not compare that means miss match( glowing red LED),then do again this process (receive char) it's working done then get "acknowledgment" through sms is done, then another process again receive char it's not compare that means miss match( glowing red LED), it's repeat again again one "acknowledgment" get from mc next receive char miss match,
Yes, you do a lot of things.
But most developers do these things outside of the ISR. They just collect the characters and either have a thread or a main loop consume characters and decide what to do.
This allows the processor to handle a large number of interrupts/second without missing critical events.
The code, as written, is more like this: strengthcoachblog.com/.../
Yes sir your right but i want one pin to monitor frequently in main loop, if it's toggle send one sms so how can i do this in main loop.....?
"Yes sir your right but i want one pin to monitor frequently in main loop, if it's toggle send one sms so how can i do this in main loop.....?"
You ask the question as if it represented a problem.
It isn't a problem. You can do it in a large number of ways.
Haven't you read about the concept of a super-loop?
en.wikibooks.org/.../Super_Loop_Architecture
http://www.keil.com/books/