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




Bookmarks