Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

Go to start after interrupt?

Status
Not open for further replies.

ipunished

Junior Member level 3
Joined
Mar 15, 2011
Messages
31
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
United Kingdom
Activity points
1,504
I understand that when an interrupt occurs the micro controller returns to where it left from..

but my interrupt consists of a stop switch, i.e. after the iterrupt I want it to stop everything..

my code consists of running a motor in a while(1) loop.. after the hardware interrupt is pressed it should stop everything and then again wait for the start button to be pressed..
i thought of calling the start button function within the ISR, but that will leave the stack uncleared.

any way to get around this?
 

kandhu26

Member level 5
Joined
Sep 7, 2009
Messages
93
Helped
13
Reputation
26
Reaction score
12
Trophy points
1,288
Location
chennai / bangalore
Activity points
1,856
could you put your code and schematic... And also you mentioned after the hardware interrupt is pressed it should stop everything, that means you want controller itself turned off or only motor... If you want whole system [controller too] to turned off i can give one solution... This can be done by putting small hardware circuit... Using OR gate [74HC1G32] and Load switch [FPF2100] you can achieve this one...

OR gate has two inputs [A and B] B should connected push button [button one end will go to input of OR gate and other end goes to VCC with pull down resistor] and A should get connected to GPIO of controller, the output of OR gate [Y] should get connected to ON [3rd pin] of FPF2100 [with pull down resistor]... The VOUT [5th pin] of FPF2100 will get connected to VCC of microcontroller...

The logic is quite simple when you press push button, the output of OR gate will be high that is connected to load switch then power goes to controller... In your program make the GPIO high [Which is connected to other input of OR gate], then continuously power goes to controller...
Then stop switch is pressed, stop everything [Like what you told]...
Again start switch pressed, Hardware will take care of everything [Except making GPIO high]...:smile:
 

ipunished

Junior Member level 3
Joined
Mar 15, 2011
Messages
31
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
United Kingdom
Activity points
1,504
Thanks for your detailed reply, kandhu,

but I dont want to turn the microcontroller completely off, as after the interrupt, I want it to wait for the start button again, I just want tahts after teh stop switch is pressed it just stops running everything, i mean send 0 to all output ports, however after that I want it to wait for the start switchg again..

my code for the ISR as of now only contains of sending 0 to teh output ports =/
 

cubanflyer

Full Member level 5
Joined
Jul 31, 2010
Messages
255
Helped
75
Reputation
152
Reaction score
71
Trophy points
1,308
Location
UK
Activity points
2,501
You could modify your code in the ISR routine, and use a simple loop waiting to the switch to be pressed again. Once it is pressed start everthing then exit the routine.
 

ipunished

Junior Member level 3
Joined
Mar 15, 2011
Messages
31
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
United Kingdom
Activity points
1,504
|I thought of that, but wont it leave teh stack mismanaged.. I mean when teh microcontroller goes to ISR, it stores what its doing on stack and then come back and pick up..
 

cubanflyer

Full Member level 5
Joined
Jul 31, 2010
Messages
255
Helped
75
Reputation
152
Reaction score
71
Trophy points
1,308
Location
UK
Activity points
2,501
When you enter the routine, it stops the interrupt process. It only stores the return address.

You need something like this


Save registers.
stop the motor.
switch all outputs to zero.

Loop waiting for the switch to be pressed again.

start up the motor
restore the outputs.

clear any interrupt flags
restore registers
exit isr
 

dayanpad

Advanced Member level 4
Joined
Mar 23, 2009
Messages
114
Helped
17
Reputation
34
Reaction score
17
Trophy points
1,298
Location
Colombo
Activity points
1,921
save registers in the ISR , swap will help you
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top