PDA

View Full Version : Stop the pic working



sgufa
- 4th July 2007, 00:48
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...

Pic_User
- 4th July 2007, 04:44
Hi sgufa,
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...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-

Melanie
- 4th July 2007, 07:03
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...



LED var PortB.1
StopPin var PortB.0

TRISB=%00000001

Loop: Toggle LED
Pause 500
While StopPin=1:Wend
Goto Loop

sgufa
- 6th July 2007, 19:06
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

mister_e
- 6th July 2007, 19:10
@ SLEEP

will do the job.

Now depending the PIC you're using, you need to be check which i/o can wake the PIC.

sgufa
- 7th July 2007, 04:09
i'm using 16f628a

can you make me an example for the sleep?

skimask
- 7th July 2007, 04:43
i'm using 16f628a

can you make me an example for the sleep?

main:
@ SLEEP
end

And judging from your other few posts...are you using PicBasicPro or Proton Basic?

sgufa
- 7th July 2007, 16:59
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

mat janssen
- 7th July 2007, 17:06
Then you are in the wrong forum.
http://www.picbasic.org/forum/
is then a better forum for you.

sgufa
- 8th July 2007, 01:55
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...

Darrel Taylor
- 8th July 2007, 02:37
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>

Pic_User
- 8th July 2007, 04:09
Hi sgufa,

to search the PICBASIC forum, try pasting this whole line into Google:

nap OR sleep 16f628a OR PIC16f628a site:http://www.picbasic.co.uk/forum/or
to search the Proton forum, try pasting this whole line into Google:

low power 16f628a OR PIC16f628a site:http://www.picbasic.org/forum/see also
Darrel Taylor’s great post:
A better Search tool for the Forum
http://www.picbasic.co.uk/forum/showpost.php?p=26311&postcount=1

-Adam-

Darrel Taylor
- 8th July 2007, 05:00
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.

@ 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


HTH,

sgufa
- 9th July 2007, 00:38
many thanks for the suggestions. I'll give it a try...