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!!>>?
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...?
A for (;;) ; at the end of the program (inside main() or added by the toolset) will also give a continuous restart if the processor has the watchdog enabled.
PK51 really adds a default LJMP to Main. In C51 examples, the Blinky example has the while(1)around the entire code. This amounts to a LJMP to main so no additional code is added. But if you comment out the while(1) and ending brace, then PK51 will add the additional LJMP to main. Bradford
if this is anything to do with keil ('51, '16x, ARM)Main() is NOT supposed to or supported at exiting.
Erik