This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

main() runs again after completion of code

Hello,
I wrote a simple c program in keil to set the voltage on/off for two motors for 10 sec. But when i debug the program, it runs correctly till the end and at the last step of the code it returns to 1st line of main()again, performing all steps again.So the program seems to run for infinite time. Can you suggest me a solution. The same code when i copied and pasted it to another file and ran it on different pc it runs well!!>>?

Parents
  • It doesn't necessarily have to be an actual loop; eg, it could be something that puts the processor into some kind of "sleep" mode...

    "If it is the PK51, then Keil always puts a default LJMP to Main at the end of your code."

    Does it?

    I thought it was effectively a

    for( ;; );
    


    ie, it gets caught in a tight loop if it "falls-through" from main...?

Reply
  • It doesn't necessarily have to be an actual loop; eg, it could be something that puts the processor into some kind of "sleep" mode...

    "If it is the PK51, then Keil always puts a default LJMP to Main at the end of your code."

    Does it?

    I thought it was effectively a

    for( ;; );
    


    ie, it gets caught in a tight loop if it "falls-through" from main...?

Children