16f88 WON'T GO TO SLEEP, please help!!


Closed Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Jun 2012
    Posts
    2

    Default 16f88 WON'T GO TO SLEEP, please help!!

    Hello guys,
    I would need some help please.
    I have a 16F88 and I am trying to use a sleep instruction in a very simple blinking LED program but it seems it does not want to work.I have tried everything with no success.Basicaly I want to put the pic to sleep and then wake up on portB change and continue the programm right after the sleep instruction, no interrupt sub routine , so INTCON,GIE is disabled.
    But the "sleep instruction does not work the PIC does not go to sleep. It works on MPLAB simulator but when I put the programm in the real PIC it does not work.It goes to sleep however if I make RB4 to RB7 outputs but ofcourse then I canot wahe-up and that is not what I want.When I set the GIE it works too, but I do not want to use ISR, I just want to wake it up and run the programm from the sleep instruction.I set RB6 as input and put a 10K pullup resistor on it. the other port B pins are outputs.I have notheing on the other pins except a MCLR button on pin RA5.I clock it with 20 Mhz crystal, I also tried it with internal osccilator. Voltage is 3V.
    I put here my program , maybe someone can help me and tell me what I am doing wrong, why it is not working.
    Thank you.
    Code:
    ;------------------------------------------------------------------------------; PROCESSOR DECLARATION;------------------------------------------------------------------------------
         LIST      p=16F88              ; list directive to define processor     #INCLUDE <p16f88.inc>          ; processor specific variable definitions
    ; ~~~~~~~~~~~~~~~ _CONFIG1 ~~~~~~~~~~~~~~~~~  ; turns off everything except MCLR and Powerup Timer     __CONFIG    _CONFIG1, _CPD_OFF & _CP_OFF & _DEBUG_OFF & _LVP_OFF & _MCLR_OFF & _PWRTE_OFF & _WDT_OFF & _WRT_PROTECT_OFF & _BODEN_OFF & _HS_OSC      __CONFIG    _CONFIG2, _IESO_OFF & _FCMEN_OFF ; --------The Internal RC Frequency can be set at any time after ORG ----------------------- ;-------------------------------------------------------------------------------
      CBLOCK h'20' 
    d1
    d2
    d3
    ENDC
    
    
    
    
    RESET     CODE    0x0000          ; processor reset vector         
    pagesel START         
    GOTO    START             ; go to beginning of program
    
    
    ;------------------------------------------------------------------------------; MAIN PROGRAM;------------------------------------------------------------------------------
    PROGRAM   CODE    
    START
    ;------------------------------------------------------------------------------;  Deactivate A/D, comparators and voltage regulator
    banksel    PORTA
    clrf    PORTA
    clrf    PORTB
    clrf    STATUS 
    clrf    CCP1CON    ; Turn off CCP  
    clrf    T1CON      ; Turn off timers  
    clrf    T2CON ;
    banksel    CMCON     ;
    movlw    07h ; Turn off comparator and make port A digital 
    movwf    CMCON ; 
    clrf    CVRCON      ; Turn off voltage regulator 
    banksel    ANSEL     ; Turn off A/D converter and make PORT A  digital, 
    clrf    ANSEL     ;
    banksel    TRISA
    clrf    TRISA
    movlw    b'00000000'
    movwf    TRISA
    movlw    b'01000000'
    movwf    TRISB
    bcf     OPTION_REG,7    ; enable pull up on port B
    ;------------------------------------------------------------------------------; PLACE USER PROGRAM HERE;------------------------------------------------------------------------------
    banksel INTCON
    bcf    INTCON,INT0IF
    bcf    INTCON,TMR0IF
    bcf    INTCON,INT0IE
    bcf    INTCON,TMR0IE
    bcf    INTCON,PEIE
    bcf    INTCON,RBIF
    bsf    INTCON,RBIE
    bcf    INTCON,GIE
    
    
    banksel PORTA
    bsf     PORTA,1
    call    delay
    bcf     PORTA,1
    SLEEP
    call    delay
    bsf    PORTA,1
    call    delay
    bcf PORTA,1
    call    delay
    bsf    PORTA,1
    goto $
    
    
    delay
    movlw    0x16
    movwf    d1
    movlw    0x74
    movwf    d2
    movlw    0x06
    movwf    d3
    Delay_1
    decfsz    d1, f
    goto    $+2
    decfsz    d2, f
    goto    $+2
    decfsz    d3, f
    goto    Delay_1
    return
    END

  2. #2
    Join Date
    Sep 2010
    Location
    Las Vegas, NV
    Posts
    305


    Did you find this post helpful? Yes | No

    Default Re: 16f88 WON'T GO TO SLEEP, please help!!

    Looks more like C than PBasic. Please post code in basic then someone might chime in and help.

  3. #3
    Join Date
    Sep 2004
    Location
    Mentor, Ohio
    Posts
    352


    Did you find this post helpful? Yes | No

    Default Re: 16f88 WON'T GO TO SLEEP, please help!!

    That's not C! It's assembly language.

    BobK

  4. #4
    Join Date
    Nov 2009
    Location
    Virginia, USA
    Posts
    10


    Did you find this post helpful? Yes | No

    Default Re: 16f88 WON'T GO TO SLEEP, please help!!

    Quote Originally Posted by BobK View Post
    It's assembly language.
    BobK
    Dirty Word !!
    Gary-W4GNS
    MicroCode Studio Plus 5.0.0.2 MCSPX
    PBP 3.0 Gold Edition 3.0.5.4

    Tickled Speechless using PBP 3.0

  5. #5
    Join Date
    Apr 2012
    Location
    Long Island, New York, USA
    Posts
    2


    Did you find this post helpful? Yes | No

    Default Re: 16f88 WON'T GO TO SLEEP, please help!!

    I believe that you need a NOP instruction after the SLEEP instruction. Regardless of the GIE setting, the instruction following the sleep instruction is executed.

  6. #6
    Join Date
    Apr 2012
    Location
    Long Island, New York, USA
    Posts
    2


    Did you find this post helpful? Yes | No

    Default Re: 16f88 WON'T GO TO SLEEP, please help!!

    in addition to my previous reply, you should look more closely at section 15.13.2 of the data sheet. there is a chance that the sleep is executing as a NOP because the RBIE and the RBIF were set prior to executing the sleep instruction.

Members who have read this thread : 1

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