Hola, yo he hecho comunicacion serial utilizando el Hardware de un PIC, Lo unico es que no uso el HSERIN, sino para recibir siempre uso interrupciones... Ademas, las interrupciones los manejo por asembler... jeje
Codigo:
DEFINE INTHAND Int_Vector " Handler de Interrupcion
asm
Int_Vector
movwf wsave ; Guardamos el registro W
movf STATUS,W
clrf STATUS ; Guardamos el registro STATUS
movwf ssave
movf PCLATH,W ; Guardamos el registro PCLATH
movwf psave
clrf PCLATH
endasm ; Código de interrupción
PIR1.5=0 ; Borramos el flag de interrupcion
Dato= RCREG ; Guardamos el dato entrante en la variable Dato
Send=1
Asm ; Fin de Interrupcion
clrf STATUS
movf psave,W
movwf PCLATH ; Restauramos el registro PCLATH
movf ssave,W
movwf STATUS ; Restauramos el registro STATUS
swapf wsave,F
swapf wsave,W ; Restauramos el registro W
retfie
endasm"****************************************************************
Inicio:
TRISC=%10000000 " Configuramos el Puerto C RS232
SPBRG=12 " Vtx=19200 baudios; Xtal=4Mhz,
RCSTA = %10010000 " Enable serial port and continuous receive
TXSTA = %00100100 " Enable transmit and asynchronous mode,8bits,Tx on
TXREG=0: RCREG=0 " aclarar buffers del port serial
PIE1=%00100000
PIR1=%00010000
INTCON=%11000000: send=0
Loop: IF send=0 then loop
PORTB=DATO
TxRS232:IF PIR1.4 = 0 Then TxRS232
TXREG = DATO
goto loop
end
Ese es parte de un codigo que siempre uso... Espero te sirva y dale una revisada porque creo que le faltan algunos pequeños detalles.
Un abrazo...