Here is a simple hardware sample to receive and send serially.
It will echo from a terminal program.
If I remember correctly mister E posted this a long time ago.
Works well for testing a setup.
Code:
DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 0
DEFINE HSER_SPBRG 129 ' 2400 Baud @ 20MHz, 0.17%
DEFINE HSER_CLROERR 1 ' Clear overflow automatically
DEFINE HSER_EVEN 1
DEFINE HSER_BITS 7
RCIF VAR PIR1.5
SERIALDATA VAR BYTE
PAUSE 100
MAIN:
IF RCIF THEN
HSERIN [SERIALDATA]
HSEROUT [SERIALDATA]
ENDIF
GOTO MAIN
Bookmarks