Is it possible to use a PIC18F2550 as a USB to RS232 adapter with PBP by using the CDC mode?
Is it possible to use a PIC18F2550 as a USB to RS232 adapter with PBP by using the CDC mode?
the microchip site has firmware to make a USB PIC into a serial convertor. It is fairly well documented. somewhere on the site
www.microchip.com
it is one of the first things i learned about when i began investigating PIC USB
-R
Or, if you wanted to stick with PicBasic, you could try the usbcdc.bas example in the USB18 folder.
DT
I have looked at booth but they are incomplete.
I have tried to capture data from the RS232 port on the pic and output it to the USB and also from the USB to the RS232 with no sucess.
All examples are just on how to emulate the CDC.
I basically need a USB to RS232 adapter like those you can buy in any store.
I have tons of these 18F2550 chips and would rather use them to convert my exsisting projects instead of going and buying some.
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
Using a MAX232 type chip in the circuit?
Depending, you might have to use N9600 instead of T9600
Bookmarks