Hello, I use the C51 compilers to compile C programs to the 87C51 microcontroller. When i compile my file, te compiler makes the program as endless loop ( The program runs continuously ). How can compile the file without this loop? Thank you very much, Sagi.
C has a built-in expectation that main() is called from an OS -- Unix -- which supplies the argc and argv parameters, and cares about the return value from main(). However, embedded devices usually start running when the power is turned on and never stop. Exiting main is usually considered to be a programming error, and restarting the program from scratch is a reasonable thing to do for an embedded compiler in that case. It's this reset that makes it look like your program is looping. Hence the need for an infinite loop to "stop" the program at the end of main. Also, your 8051 derivative may support some sort of power-down mode. You could enter that mode to stop instead of looping.