Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
MrNobody said:I am not familiar with HiTech C but I am guessing, something is not right with ur while loop. Check your while statements.. Unless you "break" it, the code inside a "while (1)" loop will repeat itself.
Why don't you post your code so that we can have a look.
Oznog said:In ALL C compilers, if the code even reaches the end of the main(){}, the part will reset and the code will run again.
If you want to do a job once upon power-up and then never do anything again (rare outside of the testbench), then you must have:
main(){
... do stuff...
while(1); //loop forever
}
Read again. That's exactly what I told you to do.vdd said:Thanks, I think I nearly got it, but still little confused.
that's the problem I'm having, the code runs to the end and reset and run again. That's what I don't want. All I want is the program will stop in what ever it told to do last and Not going back to the beginning and start again.
How do I do that?
while(LATB!=0b00001111){
clock_pin=0;
delay();
clock_pin=1;
delay();
}
while(1){
clock_pin=0;
delay();
clock_pin=1;
delay();
if(LATB==0b00001111){
break; //forcefully exit the loop
}
}