USB to RS232 adapter


Closed Thread
Results 1 to 20 of 20

Hybrid View

  1. #1
    Join Date
    Jan 2006
    Location
    Toronto
    Posts
    109

    Default USB to RS232 adapter

    Is it possible to use a PIC18F2550 as a USB to RS232 adapter with PBP by using the CDC mode?

  2. #2
    Join Date
    Jan 2007
    Posts
    70

    Default

    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

  3. #3
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959

    Default

    Or, if you wanted to stick with PicBasic, you could try the usbcdc.bas example in the USB18 folder.

    DT

  4. #4
    Join Date
    Jan 2006
    Location
    Toronto
    Posts
    109

    Default

    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.

  5. #5
    Join Date
    Jan 2006
    Location
    Toronto
    Posts
    109

    Default

    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

  6. #6
    skimask's Avatar
    skimask Guest

    Default

    Using a MAX232 type chip in the circuit?
    Depending, you might have to use N9600 instead of T9600

Similar Threads

  1. USB CDC Communications for Dummies!
    By Squibcakes in forum USB
    Replies: 104
    Last Post: - 15th January 2014, 13:43
  2. USB to rs232 emulator
    By Pic2008 in forum USB
    Replies: 0
    Last Post: - 5th March 2010, 15:54
  3. Simple USB Comms Problem
    By awmt102 in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 6th January 2010, 20:17
  4. Bafo USB to serial adapter
    By ardhuru in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 29th July 2006, 18:48
  5. USB to Serial Adapter with 9.6v
    By serandre in forum Serial
    Replies: 3
    Last Post: - 10th May 2006, 20:16

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts