16F181: can't wake up from sleep


Closed Thread
Results 1 to 8 of 8

Hybrid View

  1. #1
    Join Date
    Dec 2007
    Location
    Finland
    Posts
    191


    Did you find this post helpful? Yes | No

    Post

    Quote Originally Posted by Acetronics View Post
    3) enabling GIE sends you @ wake up ... to address 04 ( interrupt vector )
    disabling GIE ...... to the next address of your program ( @sleep +1)
    where a "nop" is highly recommended ( you did it fine ...).
    Thanks Alain for this information. I have had lots of luck with my code when GIE option was enabled. Now I will disable it immediately.

    Some lessons learnt again

    BR,
    -Gusse-

  2. #2
    Join Date
    Aug 2007
    Location
    Mississauga, Ontario, Canada
    Posts
    29


    Did you find this post helpful? Yes | No

    Default

    Hi guys... thank you for the info.
    Yes, I'm using a 16F818 chip... not really my choice but rather something that my buddy chose for his paintball gun and I'm stuck writing the software for it.

    Anyway, thanks to your suggestions I'm getting close. However, what I've noticed is that on wake up the TMR1 interrupt is disabled.
    I'm curious if this is normal and I just wonder if I need to re-enable it via the PIE register. I'll try that and see what happens.

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Gusse View Post
    Some lessons learnt <u>again</u>
    That happens to you too ? Welcome to my world
    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.

  4. #4
    Join Date
    Aug 2007
    Location
    Mississauga, Ontario, Canada
    Posts
    29


    Did you find this post helpful? Yes | No

    Default

    OK guys... got it going. Here is the snippet of the the code around the sleep command. Works like a charm.
    What I've done is I gave it a delay of 3 seconds from the closure of the switch to make sure PortB is undisturbed, then I took a snapshot of PortB (read it into a dummy variable), set up the interrupt and put the PIC to sleep. Once awoken, I read PortB again and cleared the flag.

    Now here is another question... I'm also running Darrel Taylor's interrupt routine based on TMR1. I use it to flash a LED if a battery is low.
    However, once the chip awakens from sleep, it would appear that this interrupt isn't working anymore (ie. no flashing).

    I've noticed the same thing happens if I try to declare INTCON=00001000 at the top of the program... does this make sense?

    Code:
        pause 3000
        dummyread=PortB
        intcon=%00001000
        @ sleep
        @ nop                       
        dummyread=PortB
        intcon.0=0

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. wake up from sleep
    By savnik in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 31st August 2007, 17:09
  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. 18F2320 and sleep function
    By Brian in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 10th March 2005, 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