Code:
DEFINE OSC 4
ANSEL = %00000000 ' Pins to be Digital
ANSELH = %00000000 ' Pins to be Digital
TrisA = %00000000
PortA = 0
TrisB = %00100000 ' if the only input is pin 10 Rx
PortB = 0
TrisC = %00000000 ' if none of the portC pins are used
PortC = 1
CM1CON0 =0
CM2CON0 =0
CM2CON1 =0
adcon1=0
Include "modedefs.bas"
DEFINE HSER_RCSTA 90h
DEFINE HSER_TXSTA 24h 'sets bergh = 1 or 20h sets = 0
'define HSER_BAUDCON 1h ' 0h
DEFINE HSER_BAUD 2400 '16468
DEFINE HSER_SPBRG 103
DEFINE HSER_CLROERR 1
rxVal Var word
start:
Hserout ["Hello World", 13, 10] ' Send text followed by carriage return and linef
main:
Hserin 10000,start,[rxVal] ' Get a char from serial port
Hserout ["Got value:", rxVal] ' Send char out serial port
pause 30
goto main
That's the code.
Bookmarks