I use serial comms between a PC and PIC, but not sure if this is what you are after

This is in the main program loop, which looks to see if there is a character in the buffer from the PC

Code:
FOR TempWD = 0 TO 800
    IF RCIF=1 THEN GOSUB coms                   ; Check to see id PC application connected
    PAUSE 1
NEXT TempWD
I then have this routine which will either send a string to the PC application / terminal program, or reads in the string from the PC

Code:
coms:

HSERIN [nTest]
    SELECT CASE nTest
    CASE "Q"                    ; if Q then send data to PC
    Goto Term_TX 
    CASE "S"                    ; if S then receive data from PC
    goto Term_RX
return
Rx and Tx are simple HSERIN and HSEROUT commands with the variables that make up the string of data that is received or sent.

Hope that helps