Hello,
I am trying to hook up my PIC18F4550 to my serial port and send data using Visual Basic. The code for the PIC is below. I have a 22K resistor on the RX line of the PIC. The RTS and CTS lines I have working (thanks to skimask) but I can't seem to get the RX to work. The PC should transmit a "4" and the PIC should receive it and test its value. For visual basic the instruction I am using is: SerialPort.Write("4"). I believe I have the right baud and everything setup (9600) but I can't be sure (the rest is the default setup). Any help is appreciated! Thanks,
-Mike
Code on PIC:
------------------
Include "modedefs.bas"
define HSER_CLROERR 1
define HSER_RCSTA 90h
define HSER_BAUD 9600
define HSER_TXSTA 20h
define OSC 4
rts var porta.2
cts var portd.3
led var portd.2
rx var portc.7
OK var word
input rts
output cts
output led
ADCON1 = %00001111
low led : low cts
main:
while rts = 1
high cts
SERIN rx,N9600,OK
if ok = "4" then
high led
endif
wend
low cts
goto main
Bookmarks