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 CCS Technical Support

Wakeup on pin change.. how?!

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







Wakeup on pin change.. how?!
PostPosted: Thu May 01, 2003 12:36 pm     Reply with quote

I see many references to "when configured" about waking up on a pin change, but cannot find how to configure it.

I see this #define in my 16c505.h "example"-

#define PIN_CHANGE_FROM_SLEEP 0x90

Which seems promising, but is not mentioned anywhere in the documentation.

help?

-Curt
___________________________
This message was ported from CCS's old forum
Original Post ID: 14121
Curt
Guest







Re: Wakeup on pin change.. how?!
PostPosted: Thu May 01, 2003 12:47 pm     Reply with quote

finnaly found the appropriate bit in the status register (/RBWU) and am attemptin to manually set this to '0' but how is it "supposed" to be done with the compiler? Docs are quite sketchy.

-Curt
___________________________
This message was ported from CCS's old forum
Original Post ID: 14122
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

Re: Wakeup on pin change.. how?!
PostPosted: Thu May 01, 2003 1:15 pm     Reply with quote

:=finnaly found the appropriate bit in the status register (/RBWU) and am attemptin to manually set this to '0' but how is it "supposed" to be done with the compiler? Docs are quite sketchy.
---------------------------------------------------------

The RBWU bit is in the Option register. CCS has a macro
in the EX_MACRO.C file that can be used to write to that
register. EX_MACRO.C is in c:\Program Files\Picc\Examples

Here's the macro:

<PRE>
#define set_options(value) {#ASM \
MOVLW value \
OPTION \
#ENDASM}
</PRE>

Because the Option register is Write-only, you also have
to specify the other bits properly, when you write to it.
ie., RBPU, TOCS, etc. These are discussed in the 16c505
data sheet in section 4.4.
___________________________
This message was ported from CCS's old forum
Original Post ID: 14123
Curt
Guest







Brute force solution works, but still woudl like to know how
PostPosted: Thu May 01, 2003 1:24 pm     Reply with quote

This code works-

-------------

// perform setup of environment
set_tris_b( 0x1A ); // 11010
set_tris_c( 0x0F ); // 1111

// enable wakeup-on-pin-change
#asm
movlw 0x18
option
#endasm

output_low( FET0 );

g_bTriggerState = input( TRIGGER ); // read trigger

if ( !input(L_RESET_SW) ) // its depressed, wait for it to come back up
sleep();

// okay it was released, determine power state
if ( g_onOff && !g_bTriggerState ) // was on, turn off
{
g_onOff = false;
output_low( LED );

sleep();
}
else // was off, turn on
{
g_onOff = true;
output_high( LED );
}
___________________________
This message was ported from CCS's old forum
Original Post ID: 14124
Curt
Guest







Thanks Mr. Programmer!
PostPosted: Thu May 01, 2003 1:39 pm     Reply with quote

I guess my solution was the un-macroed version Smile I appreciate your quick feedback.

-Curt
___________________________
This message was ported from CCS's old forum
Original Post ID: 14126
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