I have designed a circuit based on pic18f452 my circuit gets reset automatically while I dont wanna reset, its great problem please provide me the solution, I have used 6 analog inputs and the ground is common if i dont make the ground common then it give garbage values and not work as needed , with common ground it works right but reseting again and again.......thanks in advance please I am too confuse help
Once your code reached the last main() line and there's not any funcion or loop back, the MCU won't do anything since there is not any instruction.
Could it be the supply? Are you driving high currents from the same MCU supply? Current peaks may lower its voltage for a while and can turn off the MCU reseting it or making it to stop working till the next reset. Use fast response capacitors as ceramic near the MCU (in the PCB) of aproximately 100nF. That will help to keep the MCU turned on for that while when the current consumption is high.
if you come to the end of main() in a 'normal' program (and execute the return statement) on a PC the program stops and control returns to the operating system
in the case of an embedded system the result is unpredictable but often it will reset
put a while() loop before the end statement, e.g.
Yes, mostly you will never want programs with an end; you can idle your MCU for power saving but the program should be able to start and restart again.
Use a while(1), do ... while(1); , for(;;, etc to get a always true condition and a endless loop. That will allow your MCU to do its work all the time.