Permanent sleep


Closed Thread
Results 1 to 40 of 59

Thread: Permanent sleep

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default

    I'm talking about the GIE bit here. In the A version, if GIE is not set, the SLEEP (the Assembler instruction) is treated as a NOP and the PIC never enters SLEEP. This didn't work that way in the non-A version. I've a (fortunately) obsolete product that used that feature... otherwise I'd be scratching my head trying to figure why the product didn't work as expected!

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


    Did you find this post helpful? Yes | No

    Post The interrupt Way

    Hi, Charudatt

    Here it is :





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

    DEFINE NO_CLRWDT 1
    DEFINE INTHAND _Blink


    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 = %11111111

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

    '
    ' PIC Low-Power Sleep Routine
    ' ---------------------------
    '
    ' Set Sleep Interrupts
    ' --------------------
    INTCON=%10011000 ' 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
    INTCON.7 = 1
    '
    ' Sleep
    ' -----
    LOW LED

    High Sleepled

    @ SLEEP
    @ nop

    Blink:

    Dummy = PORTB
    Pause 100 ' Needed for system Wake-Up

    LOW SleepLed

    HIGH LED

    While ( PORTB >> 4 ) <> %00001111
    Wend

    PAUSE 200

    PAUSE 5000
    LOW LED

    GOTO CYCLE

    END



    As you see it's not so different from the "non interrupted" way ...

    But, IF I correctly understand Mel ( one more time, Mel : You're the one and Only ... !!! - no sexual meanings hidden ( LOL) ) , the interrupt way could fit both 628 and 628A ...

    I must say I used a 16F628-04 batch N° 0145H9F for tests ( I do not have any 628A ... but will run a try with a brand new 648A.

    ********************************************
    ********************************************
    A little "bug" in the "non interrupted" listing ... to correct:

    TRISB must be % 11111111 ... instead of % 01111111

    I was wondering why PortB.7 was inactive .... LOL !!!


    Have fun, and read you soon

    regards

    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 " !!!
    *****************************************

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


    Did you find this post helpful? Yes | No

    Talking Humour ...

    Those who really followed this thread have surely noticed there could have been other lines inserted between :

    @ SLEEP
    @ nop

    AND ...

    Blink:

    didn't you ??? ....

    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
    Apr 2006
    Location
    New Hampshire USA
    Posts
    298


    Did you find this post helpful? Yes | No

    Smile How about this

    Quote Originally Posted by Acetronics View Post
    Those who really followed this thread have surely noticed there could have been other lines inserted between :

    @ SLEEP
    @ nop

    AND ...

    Blink:

    didn't you ??? ....

    Alain
    Hello Alain,

    Do you mean:
    @ SLEEP
    @ nop
    snore
    Blink:
    turn-over
    @ SLEEP

    Then again, sometimes I "just don’t quite get it"...
    -Adam-
    Ohm it's not just a good idea... it's the LAW !

  5. #5
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Gotta get new glasses.

    @nap

    Did not work
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Wink

    <body onload="setInterval('blinkIt()',1000)">

    <script type="text/javascript">
    function blinkIt() {
    if (!document.all) return;
    else {
    for(i=0;i<document.all.tags('blink').length;i++){
    s=document.all.tags('blink')[i];
    s.style.visibility=(s.style.visibility=='visible') ?'hidden':'visible';
    }
    }
    }
    </script>

    <blink>@ NOP</blink>

    @nap will just define a label
    nap without the @, is a PBP function, and it's not the same as ASM
    <blink>@ NOP</blink>
    Steve

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

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


    Did you find this post helpful? Yes | No

    Default

    A half hearted compile of your code (Alian) for the 16F873A gave an error with DEFINE INTHAND _Blink.

    I changed it to DEFINE INTHAND Blink and it did not come out of sleep (I presume) the same code compiles OK for the 16F628A.

    I am sorry , I was busy with some other job, but today I shall try your code for the intended chip and post results.

    Thank you for all your help,

    regards

  8. #8
    T.Jackson's Avatar
    T.Jackson Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e View Post
    <body onload="setInterval('blinkIt()',1000)">

    <script type="text/javascript">
    function blinkIt() {
    if (!document.all) return;
    else {
    for(i=0;i<document.all.tags('blink').length;i++){
    s=document.all.tags('blink')[i];
    s.style.visibility=(s.style.visibility=='visible') ?'hidden':'visible';
    }
    }
    }
    </script>

    <blink>@ NOP</blink>

    @nap will just define a label
    nap without the @, is a PBP function, and it's not the same as ASM
    <blink>@ NOP</blink>
    C'mon Mister_e, you can do better than that! - show us all some of your "real" java skills, like scrolling some 3D text with user definable parameters.

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


    Did you find this post helpful? Yes | No

    Talking

    Quote Originally Posted by Pic_User View Post
    Hello Alain,

    Do you mean:
    @ SLEEP
    @ nop
    snore
    Blink:
    turn-over
    @ SLEEP

    Then again, sometimes I "just don’t quite get it"...
    -Adam-
    Hi, Adam

    Snore never happens ... might be a LABEL to call before !!!

    Alain
    Last edited by Acetronics2; - 15th May 2007 at 09:55.
    ************************************************** ***********************
    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 " !!!
    *****************************************

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