Permanent sleep


Closed Thread
Results 1 to 40 of 59

Thread: Permanent sleep

Hybrid View

  1. #1
    Join Date
    Sep 2003
    Location
    Vermont
    Posts
    373


    Did you find this post helpful? Yes | No

    Default

    Allain,
    I was right. Clearing GIE does work as it does on the '690. It will wake and continue without needing an interrupt handler.

    Ron

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


    Did you find this post helpful? Yes | No

    Default

    <table><td>Vermont : 1
    France : 0</td><td></td></table>
    Steve

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

  3. #3
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Ron Marcus View Post
    Allain,
    I was right. Clearing GIE does work as it does on the '690. It will wake and continue without needing an interrupt handler.

    Ron
    What about ENTERING sleep ??? 628A datasheet clearly says IF GIE = 0 , the SLEEP command is treated as a NOP ...

    I'm a bit confused here ... or I do not have the latest datasheet !!!

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  4. #4
    Join Date
    Sep 2003
    Location
    Vermont
    Posts
    373


    Did you find this post helpful? Yes | No

    Default

    The little window says if GIE is 0 and both the flag bit and enable bit are set, it will treat the sleep command as a nop. If the flag bit is cleared, it will sleep. It IS confusingly written!

  5. #5
    Join Date
    Sep 2003
    Location
    INDIA
    Posts
    161


    Did you find this post helpful? Yes | No

    Default It does not work

    ALAIN,

    It still does not work,

    "DEFINE INTHAND INIT" , maybe puts it to sleep and never comes out.
    and "DEFINE INTHAND _BLINK" keeps the led blinking.

    regards

  6. #6
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Wink The last ?

    Hi, RON

    Ok, Thanks for the explanation ...

    It really might be written instead of BUT ... : AND any interrupt ... !!!

    So, appears no real need to set the GIE bit here ...


    Back to Charudatt's program ...


    mighn't there be a PORTB reading ... ( to end the "mismatch condition" ) ???.

    Alain

    Charudatt :

    1) DEFINE ...INIT ... the result is quite normal !!! Pic wakes up to fall asleep ...

    2) if the led keeps blinking means ... the program always stay in the interrupt stubb !!! We've traced it now.

    in this case ... interrupt flags are not cleared ... : good reason, no ?
    Last edited by Acetronics2; - 13th May 2007 at 11:54.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  7. #7
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Talking Finally GOT it !!!

    Hi, Charudatt

    Straight from my test bench :


    @ __CONFIG _INTOSC_OSC_NOCLKOUT & _WDT_OFF & _LVP_OFF & _PWRTE_OFF & _CP_OFF & _BODEN_OFF

    DEFINE NO_CLRWDT 1
    DEFINE LCD_EBIT 1

    CMCON=7
    VRCON=%01101100 'VRCON bit7 is OFF for no current drain
    OPTION_REG.7 = 1 ' DISABLE INTERNAL PULLUPS
    Porta = 0
    PORTB = 0
    Trisa = %11111111
    Trisb = %01111111

    LED VAR PORTB.5
    SleepLed var PORTB.7
    Dummy var byte

    '
    ' PIC Low-Power Sleep Routine
    ' ---------------------------
    '
    ' Set Sleep Interrupts
    ' --------------------
    INTCON=%00010000 ' Interrupt Control Register
    ' 7=0 - GIE - Global Interrupt Enable
    ' 6=0 - PEIE - Peripheral Interrupt Enable
    ' 5=0 - TOIE - TMR0 Overflow Interrupt Enable
    ' 4=1 - INTE - RB0/INT Enable
    ' 3=0 - RBIE - PORTB change interrupt Enable
    ' 2=0 - TOIF - TMR0 Overflow Flag
    ' 1-0 - INTF - RB0/Ext Interrupt Flag
    ' 0=0 - RBIF - PORTB Interrupt Flag
    OPTION_REG.6=1 ' 1=RB0 Rising-Edge Trigger, 0=Falling-Edge Trigger

    PAUSE 500
    LCDOUT $FE,1
    CYCLE:
    '
    ' Reset Interrupt Flags
    ' ---------------------
    INTCON.1=0 ' Reset RB0 Flag
    INTCON.0=0 ' Reset PORTB change Flag
    '
    ' Sleep
    ' -----
    LOW LED


    LCDOUT $FE,2 , "*** SLEEPING ***"
    High Sleepled

    @ SLEEP

    Dummy = PORTB
    LOW SleepLed
    @ nop
    @ nop
    @ nop

    Pause 100 ' Needed for system Wake-Up
    HIGH LED : PAUSE 200

    LCDOUT $FE,1, " HURRY UP "

    PAUSE 5000
    LOW LED

    GOTO CYCLE

    END

    CONFIG Modified to suit MPLAB Requirements ...

    I used a LCD to show what happening and fixed LEDs for Wake (green) /Sleep ( Red ) states ...

    disabled CLRWDT PbP insertions ... ( a passing idea ??? )

    also disabled the WPU ... but that is not problematic.

    also changed LEDs PORTs ...

    As PORTB was used ... I did not try "Interrupt change on PortB" ... but works great with B.0 interrupt.

    Works fine ... as you intended to program it !!!

    Regards

    Alain
    Last edited by Acetronics2; - 13th May 2007 at 15:11.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  8. #8
    Join Date
    Sep 2003
    Location
    INDIA
    Posts
    161


    Did you find this post helpful? Yes | No

    Default Thanks

    I'll give it a shot tomorrow and post my feedback.

    regards

    p.s. Today after the failed experiments, i am planning the same thing on 16F73. Lets hope it works. I shall post my feedback on both tomorrow.
    Last edited by charudatt; - 13th May 2007 at 18:16.

  9. #9
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Wink A Beer aside for me ...

    Hi, Charudatt



    @ __CONFIG _INTOSC_OSC_NOCLKOUT & _WDT_OFF & _LVP_OFF & _PWRTE_OFF & _CP_OFF & _BODEN_OFF

    DEFINE NO_CLRWDT 1

    CMCON=7
    VRCON=%01101100 'VRCON bit7 is OFF for no current drain
    OPTION_REG.7 = 0 ' ENABLE INTERNAL PULLUPS
    Porta = 0
    PORTB = %11110001
    Trisa = %11110011
    Trisb = %01111111

    LED VAR PORTA.2
    SleepLed var PORTA.3
    Dummy var byte

    '
    ' PIC Low-Power Sleep Routine
    ' ---------------------------
    '
    ' Set Sleep Interrupts
    ' --------------------
    INTCON=%00011000 ' Interrupt Control Register
    ' 7=0 - GIE - Global Interrupt Enable
    ' 6=0 - PEIE - Peripheral Interrupt Enable
    ' 5=0 - TOIE - TMR0 Overflow Interrupt Enable
    ' 4=1 - INTE - RB0/INT Enable
    ' 3=1 - RBIE - PORTB change interrupt Enable
    ' 2=0 - TOIF - TMR0 Overflow Flag
    ' 1-0 - INTF - RB0/Ext Interrupt Flag
    ' 0=0 - RBIF - PORTB Interrupt Flag

    OPTION_REG.6=0 ' 1=RB0 Rising-Edge Trigger, 0=Falling-Edge Trigger

    CYCLE:
    '
    ' Reset Interrupt Flags
    ' ---------------------
    INTCON.1=0 ' Reset RB0 Flag
    INTCON.0=0 ' Reset PORTB change Flag
    '
    ' Sleep
    ' -----
    LOW LED

    High Sleepled

    @ SLEEP
    @ nop

    Dummy = PORTB
    LOW SleepLed
    @ nop
    @ nop
    @ nop

    Pause 100 ' Needed for system Wake-Up

    HIGH LED

    While ( PORTB >> 4 ) <> %00001111 ' Wait Key release
    Wend ' AND a PORTB Reading ...!!!

    PAUSE 200

    PAUSE 5000
    LOW LED

    GOTO CYCLE

    END


    Here it is with PORTB interrupts ... ( Note I modified all inputs to be active LOW ...)

    I think the origin of the problem is you forgot to read PORTB for the end of the mismatch condition ... wich Also locks the flag cancelling ( a RTFDatasheet for me ... )

    Heuuuuu, CHILLED, the beer, please !!!

    Alain

    PS : The interrupt way also works well ... if you're intersted in, I'll post it.
    Last edited by Acetronics2; - 13th May 2007 at 19:14.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

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


    Did you find this post helpful? Yes | No

    Default

    The original program example I posted way back during another life is valid for the non-A version of the 16F62X. In the non-A version you get a wake from sleep regardless of the state of the GIE bit. However, the operation of the GIE bit differs in the A version in that respect and Alain is correct. It teaches us all a lesson here that some of the changes between PIC versions are seriously subtle! So it's read the Datasheet - thoroughly!

  11. #11
    Join Date
    Sep 2003
    Location
    INDIA
    Posts
    161


    Did you find this post helpful? Yes | No

    Default Cheers for Beer.

    Alain

    PS : The interrupt way also works well ... if you're intersted in, I'll post it.[/QUOTE]

    Thank you very much, I am just dying to test it out.

    Yes Chilled beer for sure.

    Post the Interrupt way code, if you can, Thank you once again.

    regards

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, 10:00
  2. Battery powered applications
    By NavMicroSystems in forum Off Topic
    Replies: 7
    Last Post: - 22nd June 2009, 08:12
  3. Using Sleep
    By elec_mech in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 17th August 2008, 05:05
  4. 16F628A current high during sleep
    By Rubicon in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 9th October 2006, 11:21
  5. Wierd sleep issue
    By orca in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 14th March 2006, 23:06

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