Won't go back to SLEEP after 1st Interrupt


Closed Thread
Results 1 to 33 of 33

Hybrid View

  1. #1
    Join Date
    Mar 2009
    Location
    Colorado
    Posts
    378


    Did you find this post helpful? Yes | No

    Default I thought my code does clear interrupts???

    Jerson, thanks for your comments. However, your comments confuse me slightly: 1) I thought my code does clear the mismatch condition for both types of interrupts at the end of each IF-THEN block for each interrupt before RESUME where i read the Ports (dummy = flush or dummy = TMR0);
    2) I also thought my code does clear the intterupt flags for both types( FLUSH_INT_FLAG = 0 and TMR0_INT_FLAG = 0).
    Your comment about reading RB3 also confuses me since I am not using the RB3 as an intterupt.
    Can you please take another look at my interrupt service routine and clarify whether these coded statements are actually clearing the interrupts? Thanks!

  2. #2
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    970


    Did you find this post helpful? Yes | No

    Default

    Well yes, you are right. I guess I wasn't thinking straight when I wrote this. You are indeed clearing the RA3 port(not RB3). TMR0 needs to be cleared by writing to the flag register which you seem to be doing. The dummy=TMR0 is not needed.

    Only thing left would be to clear the flags before you 'sleep' rather than at the end of the interrupt. This will clear any conditions that occur between the interrupt end and going to sleep.

    Sorry for confusing you.

  3. #3
    Join Date
    Mar 2009
    Location
    Colorado
    Posts
    378


    Did you find this post helpful? Yes | No

    Angry Found part of the problem

    Thanks again Jerson. From everything I have read I thought the clearing of the mismatch and the clearing of the interrupt must occur before the RESUME statement at the end of an interrupt service routine?? Your suggestion to put them in the MAIN loop before the SLEEP statement is something I had not heard. I will try it to see.
    I did find part of the problem. I commented out the @ NOP statement after the @ SLEEP statement and now the power consumption is as follows:
    1) On Power up in the MAIN loop: 400 uamps
    2) During ops after Interrupt in Int_Handler: 4 mamps
    3) After completion of Int_Handlr (not sure whether program is at the SLEEP statement in the MAIN loop or not): drops back to 1.74 mamps.
    But it is obviously not back into deep sleep since it didn't go to 400 uamps after the Int_Handlr.
    4) If I remove power and then reapply power it goes to 400 umaps again.

    Any other ideas on why it apparently isn't going into deep sleep after the Int_Handlr??

  4. #4
    Join Date
    Mar 2009
    Location
    Colorado
    Posts
    378


    Did you find this post helpful? Yes | No

    Angry Clearing of mismatch and interrupts has to be at end of Int_Handlr

    I tried Jerson's suggestion to move the clearing of mismatch and interrupt flags to MAIN loop just before SLEEP statement instead of at the end of the Int_Handlr and it didn't work. It appeared to create continuous interrupts into the Interrupt handler without activation of any of the switches to do so.
    When I put the clearing of mismatches and interrupt flags back at the end of the Int_Handlr just before RESUME the interrupts work correctly again.
    Therefore, this suggestion to get the MCU back into deep sleep after servicing the interrupts didn't work.
    Any other suggestions from anyone out there on how to get this back into deep SLEEP after the interrupts are services??

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


    Did you find this post helpful? Yes | No

    Default

    Disable WDT ?
    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.

  6. #6
    Join Date
    Mar 2009
    Location
    Colorado
    Posts
    378


    Did you find this post helpful? Yes | No

    Angry WDT_OFF didn't let it go to SLEEP after 1st Interrupt

    Thanks, Joe. I changed the @ _config to WDT_OFF and it lowered power consumption slightly during the operations while in the Int_Handler sequence, but MCU still doesn't go back into SLEEP mode after the 1st Interrupt is serviced....still at 1700 uamps as opposed to 400 uamps after power up into MAIN sequence.
    Anyone else have any ideas?

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


    Did you find this post helpful? Yes | No

    Default

    Yes, turn off the WDT ... and the BOR ... and the PORTAB Pull-Ups.
    400uA is too high for sleep mode.

    But the real problem is with ANSEL.
    As trivial as it might seem, I think this will make a huge difference.

    In the Main loop ...
    Code:
    ANSEL= %11110011
    DT

Similar Threads

  1. Pin won't stay high during Repeat...Until loop??
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 17th August 2009, 00:57
  2. Battery powered applications
    By NavMicroSystems in forum Off Topic
    Replies: 7
    Last Post: - 22nd June 2009, 08:12
  3. Can't ID interrupt source with this IntHandler??
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 3rd June 2009, 03:35
  4. Using Sleep
    By elec_mech in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 17th August 2008, 05:05
  5. USART interrupt not interrupting right
    By Morpheus in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 6th March 2005, 02:07

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