your code would be helpful but here is a pointer

pinon VAR portX.Y 'eg portb.7

Pollmidi:
HSERIN [WAIT(176,44),variable]
if variable = 69 then pinon=1 'alias to port
if variable = 5 then pinon =0
goto Pollmidi


Note there is no get out of this loop but this should give you an idea.

SERIN should also work if you do not have hardware UART