Won't go back to SLEEP after 1st Interrupt


Closed Thread
Results 1 to 33 of 33

Hybrid View

  1. #1
    Join Date
    Jan 2009
    Posts
    78


    Did you find this post helpful? Yes | No

    Default use DT_interrupts

    ...use DT_interrupts...

    ...for low power consumption why you didn`t use timer1+external_32.768khz_crystal instead of timer0...the pic will stay more in sleep (timer1=16bit)

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


    Did you find this post helpful? Yes | No

    Default Don't quite understand??

    Appreciate your inputs, but don't know what you mean by DT_Interrupts. Could you explain?
    I am using the TMR0 overflow interrupt to count pulses up to a maximum of 256 pulses. That is adequate for my application. Why would I want to change over to TMR1 interrupt for 16 bits if 8 bits is enough?
    I do understand your suggestion to reduce clock speed from my current use of internal clock at 4 MHz. However I don't want to add the costl of an external crystal and capacitors. Is there a way for me to reduce clock speed at the Main code just before SLEEP and then reset clock to 4 MHz when it enters interrupt?? My understanding from the data sheet is that the clock speed has to be part of the @ config statement that is read by the compiler and can't be changed during runtime.
    Any suggestions from anyone on how to modify this code just before the @ SLEEP statment to reduce power would be appreciated. The current 400 uamps seems excessive for SLEEP mode....most posts indicate SLEEP mode for nanoWatt MCU like 16F690 should be more like a few uamps...not hundreds of uamps. >>>>

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


    Did you find this post helpful? Yes | No

    Default Back to the real problem

    I forgot to mention in my last post that the real problem I am looking for advice on is why my code doesn't put the MCU back into SLEEP mode after servicing the interrupts. Can anyone advise me? It is in SLEEP mode on power up, but after servicing the 1st interrupt will never go back into SLEEP mode as indicated by 400 uamps consumption.

  4. #4
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    967


    Did you find this post helpful? Yes | No

    Default

    How about clearing the interrupt flags before you 'Sleep' ? Also, I think you need to read RB3 to clear the flag.

  5. #5
    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!

  6. #6
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    967


    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.

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

Similar Threads

  1. Pin won't stay high during Repeat...Until loop??
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 16th August 2009, 23:57
  2. Battery powered applications
    By NavMicroSystems in forum Off Topic
    Replies: 7
    Last Post: - 22nd June 2009, 07: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, 02:35
  4. Using Sleep
    By elec_mech in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 17th August 2008, 04:05
  5. USART interrupt not interrupting right
    By Morpheus in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 6th March 2005, 01: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