Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
08/10/07 03:26
Read: times


 
#143027 - Probably this miight be happening
Responding to: ???'s previous message
Hi Michal,
I have not gone deep through your source code, but I think this is possibly what is happening:

When you write software in C/C++ for PC environment, there is always an exit point...i.e. your program must ideally give control to the Operating system and exit orderly...there are exceptions when you want your programs to stay resident...but ideally this is what the code for PC should look like...



void main (void)
{
initialize ();

...
...
for (;;)
{
...
...
if (Exit_Button)
break;
}
return ;
}




But in the case of a Microcontroller, there is no operating system. Your microcontroller must be running till the power is ON to the microcontroller hence the above code will have to be modified slightly like this:



void main (void)
{
initialize ();

...
...
for (;;)
{
...
...
// if (Exit_Button) // This not required since there is no
// break; //..exit point
}
//return ;
}



Note: There is NO exit point in your program and the for loop continues forever till the power is ON.

But if you write the program for microcontroller like the first example... the program returns and starts executing from address 0000...i.e. the boot vector and starts executing the code all over again..hence you see that the program is starting all over again and again and again....


Bye ,
With best regards from,
Kiran V Sutar
Mumbai, INDIA


List of 32 messages in thread
TopicAuthorDate
for(;;) anomally            01/01/70 00:00      
   How to post code:            01/01/70 00:00      
   re: for(;;) anomaly            01/01/70 00:00      
      malloc() on 8051?!?            01/01/70 00:00      
         Yes.            01/01/70 00:00      
            Off topic: Mixed 51 and PC mind :)            01/01/70 00:00      
         You are right            01/01/70 00:00      
   Probably this miight be happening            01/01/70 00:00      
      This sounds as a reason but...            01/01/70 00:00      
         asm            01/01/70 00:00      
            I think the same            01/01/70 00:00      
               the asm will maybe help            01/01/70 00:00      
                  Assembler codes            01/01/70 00:00      
                     Michal, you are cheating! :-)            01/01/70 00:00      
                        This was the reason :)            01/01/70 00:00      
                     ... but it's easy to do it in C :-)            01/01/70 00:00      
                        I dont trust to any any any compiler :)            01/01/70 00:00      
            Stack overflow?            01/01/70 00:00      
               I think this will be complicated            01/01/70 00:00      
                  1 of 2 ways            01/01/70 00:00      
                     Thx            01/01/70 00:00      
         The Compiler does not protect you            01/01/70 00:00      
            Like SDCC...            01/01/70 00:00      
               Better?            01/01/70 00:00      
                  option --main-return            01/01/70 00:00      
                     SDCC function startup code            01/01/70 00:00      
                        use a cookie near the end of the stack?            01/01/70 00:00      
                           rock bottom            01/01/70 00:00      
                           Why only 0xF8?            01/01/70 00:00      
                              paranoia!)            01/01/70 00:00      
               also Keil?            01/01/70 00:00      
            I have while(1) loop in main()            01/01/70 00:00      

Back to Subject List