How to stop the pic working when 1 input goes high? And how to make it resume when the same imput goes low? Please help me...
Printable View
How to stop the pic working when 1 input goes high? And how to make it resume when the same imput goes low? Please help me...
Hi sgufa,You could try the sleep command. Don’t forget the watchdog timer, make sure it is turned on.
Wake up little PIC!
http://www.picbasic.co.uk/forum/showthread.php?t=6377
Permanent sleep
http://www.picbasic.co.uk/forum/showthread.php?t=3128
Try searching the forum for sleep.
Hope that helps,
-Adam-
You've not specified the reasons why the PIC should be stopped (or indeed your definition of 'Stop', or how quickly it should happen, or the state of the PIC when it is stopped), so to experiment, why not simply start with...
Code:LED var PortB.1
StopPin var PortB.0
TRISB=%00000001
Loop: Toggle LED
Pause 500
While StopPin=1:Wend
Goto Loop
many thanks melanie but i've just did the same. In that way the pic is always ON. I'd want to put the pic in low power mode when the input goes high and then, when the input returns low, wake up the pic in order to resume his work
@ SLEEP
will do the job.
Now depending the PIC you're using, you need to be check which i/o can wake the PIC.
i'm using 16f628a
can you make me an example for the sleep?
I imagined that
but i mean an example with the routine for sleep and awake on input HI/lo
P.S. I use proton+ picbasic v3
Then you are in the wrong forum.
http://www.picbasic.org/forum/
is then a better forum for you.
assuming that Basic is always Basic if anyone is so gentle in showing me how to make my goal, i think I'm able to "port" the code from picbasicpro to proton...
I think Melanie's example in post #3 should do the trick.
Is there something different that you need?
Added: Oops, looking for low power mode. Re-thinking.
<br>
Hi sgufa,
to search the PICBASIC forum, try pasting this whole line into Google:
orCode:nap OR sleep 16f628a OR PIC16f628a site:http://www.picbasic.co.uk/forum/
to search the Proton forum, try pasting this whole line into Google:
see alsoCode:low power 16f628a OR PIC16f628a site:http://www.picbasic.org/forum/
Darrel Taylor’s great post:
A better Search tool for the Forum
http://www.picbasic.co.uk/forum/show...11&postcount=1
-Adam-
Ok, this would be for PicBasic Pro. Tested on an 877, but it should still work with a 628.
How you do it in Proton, I haven't got a clue.
HTH,Code:@ DEVICE WDT_OFF ; Disable Watch-Dog timer
DEFINE OSC 4
LED VAR PORTB.1
StopPin VAR PORTB.0
INTEDG VAR OPTION_REG.6 ; 0 = falling edge, 1 = rising
INTE VAR INTCON.4 ; External interrupt Enable bit
INTF VAR INTCON.1 ; External interrupt Flag
Delay VAR WORD
INPUT StopPin ; Is already default, but just to make sure
INTEDG = 0 ; Interrupt on falling edge
INTE = 1 ; Enable External Interrupts
Main:
Toggle LED
For Delay = 1 to 500
PAUSE 1
IF StopPin = 1 THEN
LOW LED ; Turn OFF anything that will draw current
INTF = 0 ; Clear the Interrupt Flag
@ SLEEP ; enter Low Power mode
GOTO MAIN
endif
NEXT Delay
Goto Main
many thanks for the suggestions. I'll give it a try...