Here's something to play with.
Code:
' Program to echo incoming serial data
' Baudrate : 2400 Bauds
' Method : Polling USART interrupts flags
' Pic Definition
' ==============
' Using PIC 18F2320 @ 4MHZ and bootloader
'
DEFINE LOADER_USED 1
DEFINE OSC 4
' Hardware configuration
' ======================
'
'
TRISC = %10000000 ' PORTC.7 is the RX input
' PORTC.6 is the TX output
' Serial communication definition
' ===============================
' Using internal USART and MAX232 to interface to PC
'
RCSTA = $90 ' enable serial port,
' enable continuous receive
'
TXSTA = $24 ' enable transmit,
' BRGH=1
'
SPBRG = 103 ' set baudrate to 2400
' Alias definition
' ================
'
'
RCIF VAR PIR1.5 ' Receive interrupt flag (1=full , 0=empty)
TXIF VAR PIR1.4 ' Transmit interrupt flag (1=empty, 0=full)
OERR var RCSTA.1 ' Overrun error
CREN var RCSTA.4 ' Continuous receive
' Hardware initialisation
' =======================
'
'
pause 10 ' safe start-up delay
Main:
if oerr then ' Overrun error?
cren=0 ' clear it
cren=1
endif
if RCIF then ' incomming data?
TXREG=RCREG ' take it, send it
while TXIF=0 ' wait untill transmit buffer is empty
wend
endif
goto main
the following use HSERIN/HSEROUT statement. Since your PIC have internal USART... why not using it 
Code:
' Program to echo incoming serial data
' Baudrate : 2400 Bauds
' Method : Polling USART interrupts flags
' Pic Definition
' ==============
' Using PIC 18F2320 @ 4MHZ and bootloader
'
DEFINE LOADER_USED 1
DEFINE OSC 4
' Hardware configuration
' ======================
'
'
TRISC = %10000000 ' PORTC.7 is the RX input
' PORTC.6 is the TX output
' Serial communication definition
' ===============================
' Using internal USART and MAX232 to interface to PC
'
DEFINE HSER_RCSTA 90h ' enable serial port,
' enable continuous receive
'
define HSER_TXSTA 24h ' enable transmit,
' BRGH=1
'
define HSER_SPBRG 103 ' set baudrate to 2400
DEFINE HSER_CLOERR 1 ' automatic clear overrun error
' Alias definition
' ================
'
'
RCIF VAR PIR1.5 ' Receive interrupt flag (1=full , 0=empty)
TXIF VAR PIR1.4 ' Transmit interrupt flag (1=empty, 0=full)
' Variable definition
' ===================
'
'
SerialData var byte
' Hardware initialisation
' =======================
'
'
pause 10 ' safe start-up delay
Main:
if RCIF then ' incomming data?
hserin [Serialdata] ' take it
hserout [serialdata] ' send it
endif
goto main
hope this help
Bookmarks