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