CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Not Wake up from Sleep with INT_RB

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
soonc



Joined: 03 Dec 2013
Posts: 215

View user's profile Send private message

Not Wake up from Sleep with INT_RB
PostPosted: Tue Feb 10, 2015 3:48 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Feb 10, 2015 5:24 pm     Reply with quote

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

View user's profile Send private message

Problem solved !
PostPosted: Tue Feb 10, 2015 6:04 pm     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group