I am new to c and keil. When I try to debug my code, this error message appeared. May anyone help me to find out where I got wrong? Thanks a lot.
Here is my code:
#include <reg51.h> #include "IOPort.h" unsigned char pulse1[]={9, 3, 6, 12}; unsigned char pulse2[]={2, 3}; unsigned char pulse3[]={0, 1};
delay(int d) {
int i; for (i=0;i<d;i++); }
forward () {
int j,c,no;
for (c=0;c<25;c++)
{
no=1;
for (j=no;j>=0;j--)
P1 = pulse2[j];
delay(1000);
}
main() {
forward(); }
1) Why didn't you post your source code tagged as source code? It was described clearly how to do it directly above the text input box.
2) Your main() don't have an infinite loop at the end - where do you think your program will jump when it ends? Is it meaningful for a program in an embedded device to end? Is there any command line (CLI) or graphical interface (GUI) that will continue to run after your program ends? What is the processor expected to spend the rest of the time doing, until you power off your device?
3) You never mention what processor you have, or what memory settings you have specified in the project settings.
Sorry for I didn't metion that how to post sourse code. About there is no infinity loop,I just want it to let a stepping motor to turn some step, and stop. So I didn't use a infinity loop. The possessor i use is winbound w77e58.
It doesn't really matter what you wanted your program to do - you should still not let the program drop out of main(). The startup file _might_ have a jump so it restart your program again, and again, and again. Or there _might_ be an infinite loop that catches the execution. Or the processor _might_ start to run undefined instructions while plowing through the memory.
By the way - what answers did you find when you entered your error message in Google? Because, as you should be able to suspect, you aren't the first person who gets this error message...
Thanks for your reply. I really don't know a program need to be terminate. I think I should study how to use c language again. And, actually I had google it before, though I still can't figure out how to debug my code... I think the reason is that I don't have enough background knowledge. Again, thank you.