View previous topic :: View next topic |
Author |
Message |
Curt Guest
|
Wakeup on pin change.. how?! |
Posted: Thu May 01, 2003 12:36 pm |
|
|
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?! |
Posted: Thu May 01, 2003 12:47 pm |
|
|
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
|
Re: Wakeup on pin change.. how?! |
Posted: Thu May 01, 2003 1:15 pm |
|
|
:=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 |
Posted: Thu May 01, 2003 1:24 pm |
|
|
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! |
Posted: Thu May 01, 2003 1:39 pm |
|
|
I guess my solution was the un-macroed version I appreciate your quick feedback.
-Curt
___________________________
This message was ported from CCS's old forum
Original Post ID: 14126 |
|
|
|