12F629 Won't SLEEP


Closed Thread
Results 1 to 8 of 8

Hybrid View

  1. #1

    Default 12F629 Won't SLEEP

    I can't get this PIC to SLEEP with the following program:

    CMCON = %00000111
    TRISIO = %001100
    OPTION_REG = %01000000
    PIR1 = 0
    GPIO = 0
    @ DEVICE MCLR_OFF, INTRC_OSC, WDT_OFF, BOD_OFF, PWRT_OFF, PROTECT_OFF

    'GPIO.0 =
    'GPIO.1 = LED HIGH OUT
    'GPIO.2 = SWITCH HIGH INPUT
    'GPIO.3 = MCLR TIED HIGH
    'GPIO.4 =
    'GPIO.5 =

    GPIO.1 = 1
    PAUSE 100

    INTCON = %00000000
    FLAGS = 0
    @SLEEP
    GPIO.1 = 0

    The LED goes on briefly, and then turns off. If it really does go to SLEEP, then something is waking it up. Help please!

  2. #2


    Did you find this post helpful? Yes | No

    Default

    Nevermind! GPIO.2 was tied high due to a wiring error. Datasheet says this will interrupt SLEEP, regardless of INTCON settings. Works O.K. now.

  3. #3


    Did you find this post helpful? Yes | No

    Default

    O.K., I give up. The name of this thread should be 12f629 wakes up unexpectedly. Here is the latest code:

    CMCON = %00000111
    TRISIO = %001100
    OPTION_REG = %10000000
    PIR1 = 0
    GPIO = $000000
    @ DEVICE MCLR_OFF, INTRC_OSC, WDT_OFF, BOD_OFF, PWRT_ON, PROTECT_OFF

    'GPIO.0 =
    'GPIO.1 = LED HIGH OUT
    'GPIO.2 = SWITCH HIGH INPUT
    'GPIO.3 = MCLR TIED HIGH
    'GPIO.4 =
    'GPIO.5 =

    GPIO.1 = 1
    PAUSE 100

    INTCON = %00000000
    FLAGS = 0
    @SLEEP
    NOP
    GPIO.1 = 0

    I have checked all pins with a scope, added decoupling capacitors on the +5 volt and MCLR pins, and the result is always the same. If the last line of the program is present, the LED goes out. So clearly something is causing the PIC to wakeup. What am I missing?

  4. #4


    Did you find this post helpful? Yes | No

    Default

    Is my problem so stupid that no one will give me suggestions? I believe I have read everything, and tried many things. Please help. Thank you.

  5. #5
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Put a space between @ and SLEEP.

    Edit: I guess this bears a little more detail. What happens is by placing @SLEEP in
    there it doesn't generate code for SLEEP, so you land on the next valid instruction
    which would be your GPIO.1 = 0.

    You don't have the @ symbol before your NOP either, so PBP creates a lable instead
    of code for the NOP. @ NOP would be the correct way to insert an assembly NOP
    instruction.
    Last edited by Bruce; - 22nd August 2008 at 21:39. Reason: Explanation
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  6. #6
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by jderson View Post
    Is my problem so stupid that no one will give me suggestions? I believe I have read everything, and tried many things. Please help. Thank you.
    Might just be only BRUCE saw the problem.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  7. #7


    Did you find this post helpful? Yes | No

    Default

    Thank you Bruce and Joe! The space solved the problem. Staring me in the face all along!

  8. #8


    Did you find this post helpful? Yes | No

    Default

    well, that explains why i couldn't get a pic to sleep either. lol

Similar Threads

  1. Won't go back to SLEEP after 1st Interrupt
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 32
    Last Post: - 29th June 2009, 09:00
  2. sleep on 12f629
    By sirvo in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 8th February 2007, 14:08
  3. 16F628A current high during sleep
    By Rubicon in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 9th October 2006, 10:21
  4. Wierd sleep issue
    By orca in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 14th March 2006, 22:06
  5. Programming 12F629 low power (Sleep)
    By Warrier in forum mel PIC BASIC Pro
    Replies: 17
    Last Post: - 29th November 2004, 14:45

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