It took me a while to find one the color of my truck..;o)
Experiment with this one too. You can have it wake from sleep without an interrupt handler.
Global interrupts are disabled. Just enabled the int-on-change by setting RBIE, clearing RBIF, and it sleeps until a button is pressed.Code:DEFINE OSC 4 CMCON=%00000111 VRCON = 0 PAUSEus 10 TRISA = %00000110 TRISB = %11110000 ' using upper 4-bits for interrupt PORTA = %00000000 PORTB = %00000001 OPTION_REG.7 = 0 OPTION_REG.6 = 0 led var portA.3 INTCON = %00001000 ' int-on-change enabled. RBIE=1, RBIF=0 cycle: HIGH led pause 100 LOW led pause 100 @ Sleep ' sleep until button press WHILE (portB >> 4) !=15 ' wait for button release PAUSE 10 ' and read port so RBIF can WEND ' be cleared below. INTCON.0=0 ' now clear RBIF int flag goto cycle END
DT_INTs is more fun, but you can wake one up without an interrupt handler.




Bookmarks