Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics 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.

Microcontrollers runtime pause

Status
Not open for further replies.

Solar000

Member level 2
Joined
Feb 6, 2013
Messages
49
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Location
Greece
Activity points
1,649
Hi, I would like to know if it's posssible to pause the execution of the code running from a microcontroller (pic 16f877a) with a button.
For example place a button on the pcb and when it starts running the programm,
press the button and pause the execution.When you press it again resume from the point it stopped and not beginnig from the start.

Is it possible and what components i have to add to my circuit to do that ?
Thanks.
 

That shouldn't be too hard. You can put the button on the B port and invoke an interrupt and have your main code as a state machine. So you are running through your states in code and when the interrupt is detected it would save the current state as a variable and put the code in the pause state. I think that should be about that.
 
Or if you are careful, AC ground the oscillator output pin. The 16F877A contains all static registers so if you stop the clock, the whole IC freezes. Be careful if you enable the watchdog timer (WDT) because It runs from it's own intenal oscillator and may try to reset the processor if the main clock stops. You might find it resets as soon as the main clock resumes.

Another way might be to use the internal debugging mode which I believe allows single stepping through the code so must have the ability to halt the program. I have never used it myself and there isn't much information in the data sheet.

Brian.
 
Thank you for both answers. My first thought is to do the second with the oscillator ground because i dont have to use a port.

So if i do this, i connect a pin of the button to the output of the oscillator and the other pin of button to the ground?
My circuit works with DC. Does it matter ?(because you say AC ground)
The watchdog timer can be disabled from my programm i think. Is it right?
 

You have to disable the watchdog timer during the programming process, it can't be done under software control on that PIC.

Yes, I meant to connect the clock input pin to VSS but do it through a capacitor (~1nF). It will be sufficient to stop the oscillator running but wont change the DC conditions on the pin. Beware that the clock will take a few cycles to stabilize again when you disconnect the capacitor.

Brian.
 

Ok,i attach a picture to show you if it is correct.
The ground goes to 13 pin clock input .(or output as you said at your first post?)

And about the time,
you mean press the button , after 1 second pause, press again and after 1 second resume?
 

Attachments

  • pause.jpg
    pause.jpg
    452.4 KB · Views: 102

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top