Ok, I got it to go from USB to the RS232 but I still cannot get the RS232 to USB to work. Here is the code I have so far.
Code:
DEFINE OSC 48
INCLUDE "modedefs.bas"
Buffer VAR BYTE[16]
Cnt VAR BYTE
B0 VAR BYTE
PIC_TX VAR PORTC.6 ' Transmit Pin
PIC_RX VAR PORTC.7 ' Receive Pin
ADCON1 = 15 ' Set all I/Os to Digital
INTCON2.7 = 1 ' Disable PortB Pullups
CMCON = 7 ' Disable Comparators
USBInit
' Main Program Loop
MainLoop:
USBService ' Must service USB regularly
cnt = 16
USBIn 3, Buffer, Cnt, MainLoop
SEROUT2 PIC_TX,84,[STR Buffer\Cnt]
Get_RS232_Data:
SERIN PIC_RX,T9600,100,Get_RS232_Data_Timeout,B0
Buffer[0] = B0
Cnt = 1
GOTO OutLoop
Get_RS232_Data_Timeout:
Buffer[0] = 0
Cnt = 0
OutLoop:
USBService ' Must service USB regularly
IF Cnt > 0 Then
USBOut 3, Buffer, Cnt, OutLoop
ENDIF
GOTO Mainloop
Bookmarks