its not in the code you have posted
this code as suggested by henrik works as expected
Code:
#CONFIG
__config _HS_OSC & _WDT_ON & _PWRTE_OFF & _MCLRE_ON & _BODEN_ON & _LVP_OFF & DATA_CP_OFF & _CP_OFF
#ENDCONFIG
DEFINE OSC 8
DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
DEFINE HSER_TXSTA 20h ' Enable transmit, BRGH = 0
DEFINE HSER_SPBRG 12 ' 9600 Baud @ 8MHz, 0.16%
DEFINE HSER_CLROERR 1 ' Clear overflow automatically
TRISB=%11111111 'Make RB0 input
char var byte
CMCON=7
Main:
HSERIN 5000, Timeout, [char]
IF (char="A") THEN
GOSUB somewhere
ENDIF
Goto Main
Somewhere:
HSEROUT["I got an A", 13]
RETURN
Timeout:
HSEROUT["Nothing for the last 5 seconds, I'll just restart and wait 5 more....",13]
Goto Main
Bookmarks