Problems with wake-up from sleep
I too am having problems with the interrupt-on-PORTB and waking from sleep.
I'm using Oshonsoft PIC18 and it's very nice piece of kit.
I'm sure that the pull-ups do work in Oshonsoft, since I use them on PortB pins 5-7 and my pushbuttons pull to ground. I use INTCON2.RBPU = 0 to enable pull-ups (note the bit has to be cleared, not set to enable pull-up resistors).
So when I use the test condition If PORTB.5=0 it works, when the button is pressed.
I have the problem that when I enable interrupt on PORTB change, it fires all the time, even when a button isn't pressed. Code to put the PIC to sleep is this:
tmpbyte0 = PORTB 'dummy read of PORTB
INTCON.RBIE = 1 'enable interrupt on change for PORTB[4-7]
High PORTE.2 'for testing
'actually put the device to sleep
WaitMs 500
ASM: sleep
ASM: nop
My wakeup interrupt code reads:
If INTCON.RBIF = 1 Then
'testing
Low PORTE.2 'led to show we've woken from sleep
INTCON.RBIE = 0 'clear bit
... do rest of wakeup routine here ....
End if
But no sooner has my PIC gone to sleep, than it wakes up again and the LED goes out again!
I've tried enabling global interrupts and putting the wakeup code in the interrupt, and also disabling global interrupts and putting the wakeup code after the sleep command. In both cases, the led lights to say the PIC is going to sleep, then goes out indicating that the wakeup routine has executed.
Did anyone get anywhere with this one? I'd love some help too.......
Hi,
The pullup feature dosnt appear to work in Oshonsoft, I will have to confirm this.?
Look at these two attachments, they may help.