View previous topic :: View next topic |
Author |
Message |
soonc
Joined: 03 Dec 2013 Posts: 215
|
Not Wake up from Sleep with INT_RB |
Posted: Tue Feb 10, 2015 3:48 pm |
|
|
The code issues a sleep()
If the hardware causes an interrupt on RB0 it wakes up as expected.
I also have hardware attached to RB4 and have enabled the interrupt on change.
The data sheet for PIC18LF26K22 says
Quote:
"This interrupt can wake the device from the Sleep
mode, or any of the Idle modes. The user, in the
Interrupt Service Routine, can clear the interrupt in the
following manner:
a) Any read or write of PORTB to clear the mismatch
condition (except when PORTB is the source or destination
of a MOVFF instruction).
b) Execute at least one instruction after reading or
writing PORTB, then clear the flag bit, RBIF."
End Quote
Code: |
int B;
B = input_b(); // This generates a MOVFF instruction !
B = portB; // This generates a MOVFF instruction ! |
So I tried using this
Code: | #use fast_io(b)
#byte portB = 0XF81
|
and in the isr do this:
Code: |
#INT_RB
void RB_isr(void)
{
n8LinkLost = bit_test(portB,4); // does not use MOVFF
#asm
nop;
#endasm
clear_interrupt(INT_RB); // clear the flag.
}
|
The interrupt happens but does not wake up the the sleeping PIC.
I suspect I missed something !
What am I missing ? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Feb 10, 2015 5:24 pm |
|
|
Can you post a small but complete test program ? I would like to see
your complete interrupt setup code, and sleep() function, and the code
that comes after it, and also the PortB pullups setup code, if you're not
using external pullups.
A small but complete (and compilable) program would be best.
Also post your compiler version. |
|
|
soonc
Joined: 03 Dec 2013 Posts: 215
|
Problem solved ! |
Posted: Tue Feb 10, 2015 6:04 pm |
|
|
PCM programmer wrote: | Can you post a small but complete test program ? I would like to see
your complete interrupt setup code, and sleep() function, and the code
that comes after it, and also the PortB pullups setup code, if you're not
using external pullups.
A small but complete (and compilable) program would be best.
Also post your compiler version. |
Obs ! thanks for the suggestion... I should have used a different approach in the sleep function.
The PIC did wake up but was trapped so as a quick fix I added a global var and set it in the #INT_RB isr(). That allowed the function where sleep was invoked to exit.
Thanks for the help. |
|
|
|