wake on serial input example, you would need to add code to eliminate floating inputs and disable unused "modules" to get the
absolute minimum power use.


this wakes on any serial input and goes back to sleep if an "A" is not received


Code:
;16f628a #CONFIG
  __config   _HS_OSC & _WDT_OFF & _PWRTE_OFF & _MCLRE_ON & _BODEN_ON & _LVP_OFF & DATA_CP_OFF & _CP_OFF
#ENDCONFIG
include "dt_ints-14.bas"


DEFINE OSC 8


RCSTA = $90 ' Enable serial port & continuous receive
TXSTA = $20 ' Enable transmit, BRGH = 0
SPBRG = 12  ' 9600 Baud @ 8MHz, 0.16%
asm
INT_LIST macro 
       INT_HANDLER RX_INT  , _RX, asm,NO      
      endm
      INT_CREATE
ENDASM


wsave var byte $20 system
wsave1 var byte $a0 system ; If device has RAM in bank1
wsave2 var byte $120 system ; If device has RAM in bank2


LED VAR PORTB.7
TRISB=%01111111 'Make RB0 input
BUFF var byte
FLAG var byte
CMCON=7
FLAG=0
LED=1
PAUSE 500
HSEROUT["READY",13,10]
@ int_enable RX_INT


Main:
LED=0
@ SLEEP
LED=1
  IF (FLAG) THEN
    GOSUB somewhere
  ENDIF
PAUSE 50   
Goto Main
Somewhere:
   HSEROUT["I got an A", 13,10]
   FLAG=0
RETURN




RX:
asm 
    MOVLW "A"
    BANKSEL RCREG
    SUBWF  RCREG,W
    BTFSS  STATUS,Z
    GOTO EXT
    BANKSEL _FLAG
    BSF   _FLAG,0
EXT   
    BANKSEL 0
    INT_RETURN
endasm