Stop the pic working


Closed Thread
Results 1 to 14 of 14
  1. #1
    Join Date
    Jul 2007
    Posts
    8

    Default Stop the pic working

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

  2. #2
    Join Date
    Apr 2006
    Location
    New Hampshire USA
    Posts
    298


    Did you find this post helpful? Yes | No

    Post Stop and Go....

    Hi sgufa,
    Quote Originally Posted by sgufa View Post
    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-
    Ohm it's not just a good idea... it's the LAW !

  3. #3
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    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

  4. #4
    Join Date
    Jul 2007
    Posts
    8


    Did you find this post helpful? Yes | No

    Default

    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

  5. #5
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    @ SLEEP

    will do the job.

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

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  6. #6
    Join Date
    Jul 2007
    Posts
    8


    Did you find this post helpful? Yes | No

    Default

    i'm using 16f628a

    can you make me an example for the sleep?

  7. #7
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by sgufa View Post
    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?
    Last edited by skimask; - 7th July 2007 at 05:55.

  8. #8
    Join Date
    Jul 2007
    Posts
    8


    Did you find this post helpful? Yes | No

    Default

    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

  9. #9
    Join Date
    Oct 2003
    Location
    holland
    Posts
    251


    Did you find this post helpful? Yes | No

    Default

    Then you are in the wrong forum.
    http://www.picbasic.org/forum/
    is then a better forum for you.

  10. #10
    Join Date
    Jul 2007
    Posts
    8


    Did you find this post helpful? Yes | No

    Default

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

  11. #11
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    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>
    Last edited by Darrel Taylor; - 8th July 2007 at 02:39. Reason: Oops.
    DT

  12. #12
    Join Date
    Apr 2006
    Location
    New Hampshire USA
    Posts
    298


    Did you find this post helpful? Yes | No

    Default searching for sleep

    Hi sgufa,

    to search the PICBASIC forum, try pasting this whole line into Google:
    Code:
    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:
    Code:
    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/show...11&postcount=1

    -Adam-

  13. #13
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    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.
    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
    HTH,
    DT

  14. #14
    Join Date
    Jul 2007
    Posts
    8


    Did you find this post helpful? Yes | No

    Smile

    many thanks for the suggestions. I'll give it a try...

Similar Threads

  1. Presetting Configuration Fuses (PIC Defines) into your Program
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 82
    Last Post: - 15th December 2013, 09:54
  2. PIC powered by capacitor for 0,5 second
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 18
    Last Post: - 25th August 2007, 09:23
  3. VB sending serial data to PIC
    By Tissy in forum Serial
    Replies: 7
    Last Post: - 8th March 2006, 18:31
  4. Serial Pic to Pic using HSER
    By Chadhammer in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 11th March 2005, 23:14
  5. 256 Pics Communicate to 1 Master Pic
    By mazlan in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 15th July 2004, 13:11

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts