Dead end

For C and ASSEMBLY users to post questions and code snippets for programming in C and ASSEMBLY. And for any other C or ASM course related questions.

Moderators: Benj, Mods

Post Reply
User avatar
Jan Lichtenbelt
Posts: 797
Joined: Tue Feb 17, 2009 8:35 pm
Location: Haren GN, the Netherlands
Has thanked: 128 times
Been thanked: 264 times
Contact:

Dead end

Post 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

User avatar
Steve
Matrix Staff
Posts: 3424
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times
Contact:

Re: Dead end

Post by Steve »

To stop the program, you could enter an infinite loop (e.g. a While loop with "1" as the condition).

User avatar
Jan Lichtenbelt
Posts: 797
Joined: Tue Feb 17, 2009 8:35 pm
Location: Haren GN, the Netherlands
Has thanked: 128 times
Been thanked: 264 times
Contact:

Re: Dead end

Post by Jan Lichtenbelt »

An erndless loop does not set all outputs on 0. I need a realy fast dead end.

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Dead end

Post 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
Martin

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Dead end

Post 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.

Post Reply