I think you need to read portb after you awake from sleep to clear the mismatch.
At the top
Place this after your sleep commandCode:Dummy var Byte
Code:Dummy = PORTB
I think you need to read portb after you awake from sleep to clear the mismatch.
At the top
Place this after your sleep commandCode:Dummy var Byte
Code:Dummy = PORTB
Last edited by mark_s; - 23rd November 2015 at 14:56.
Hello Mark and thanks for your answer, but it doesn't work...
It happens the same thing, enter the first time, and after that, never enter in sleep again.
I include the "On interrupt goto..." . In this case, the first time it works as expected, but after wakeup the first time, enter in loop in subprogram "Wakeup".
If anyone coul help, i'm lost...
Thanks,
Nuno
Hi
I dug up some old code I did on a pic16f819. Maybe it will help? I did not see Intcon.7 set in your code?
Place this above your variable declaration
SleepCode:OPTION_REG.6 = 0 'INTERUPT PORTB.0 ON 1 = RISING EDGE 0 = falling INTCON.4 = 1 'ENABLE RBO INTERUPT
Code:SLEEPLOOP: 'OPTION_REG.7 = 0 'ENABLE PULLUP RESISTORS PORTB INTCON.7 = 1 'ENABLE GLOBLE INTERUPTS @ SLEEP ;ASSEMBLY SLEEP COMMAND - TURNOFF uP CLOCK INTCON.7 = 0 'ON INTERUPT DISABLE GLOBLE INTERUPTS INTCON.1 = 0 'RESET INTERUPT FLAG
I don’t know how PBP interrupts work, but yes you do have to clear the interrupt flag.
This is in a case where the interrupt could have been triggered by more than one event.Code:if INTCON.1 = 1 then ' check if portb.0 interrupt occurred ‘ do the thing you wanted portb.0 interrupt to make happen INTCON.1 = 0 ' clear portb.0 interrupt flag endif
Last edited by Art; - 24th November 2015 at 18:03.
Thanks everyone.
The major problem, was a pull down button RB0, that was not working correctly.
Thanks,
Nuno
Bookmarks