Page 1 of 1

Dead end

Posted: Mon Oct 03, 2011 12:01 pm
by Jan Lichtenbelt
Hi all,

I want in a certain desicion to stop the program. I used the C-code exit(0); But I got a C-code error. What to do?

Thanks for your help

Jan

Re: Dead end

Posted: Mon Oct 03, 2011 12:22 pm
by Steve
To stop the program, you could enter an infinite loop (e.g. a While loop with "1" as the condition).

Re: Dead end

Posted: Mon Oct 03, 2011 12:45 pm
by Jan Lichtenbelt
An erndless loop does not set all outputs on 0. I need a realy fast dead end.

Re: Dead end

Posted: Mon Oct 03, 2011 1:16 pm
by medelec35
Hi Jan
I would not a thought just stopping a program would not reset variables anyway.
Im with Steve. So expanding on the endless loop.
Can’t you have an endless loop as Steve suggested, but inside the loop set all variables to 0 (or set variables, o/p's etc to 0 at the beginning of the interrupt macro).
The endless loop can be called via RB0 external int?
So if RB0 goes high or low, the macro will be instantly called that resets all variables.
That would be a fast dead end!

Martin

Re: Dead end

Posted: Tue Oct 04, 2011 1:11 pm
by Benj
Hello,

If you can rig up a PNP transistor to your MCLR signal then pulling the base of the transistor high would effectivly stop your device and reset all the I/O registers etc. If you have a latch on your base signal too then the latch would stop the device from running again until you reset the latch.