Usb to serial converter with pic18f


+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2009
    Posts
    716

    Default Usb to serial converter with pic18f

    Hi,
    I'm working on redesign device which have PL2303 and few passives components, and transistors. My idea is to replace PL2303 with PIC18F and to add more functionality.
    But I do not know how to send serial port settings(baud rate, parity, etc) from PC to PIC.
    Does any one have idea where to start? Custom drivers for windows

  2. #2
    Join Date
    Sep 2009
    Posts
    716

    Default Re: Usb to serial converter with pic18f

    Update:
    Just found that microchip usb stack 2.x support notification system when baud rate is changed on host.
    Is there any way to implement that on existing cdc example for PBP?

  3. #3
    Join Date
    Sep 2009
    Posts
    716

    Default Re: Usb to serial converter with pic18f

    I run into same issue, again. I needed to create full serial port emulator, like FT232, and to do some other things with pic.
    I spent almost a week, trying to get C to work, and decided to give PBP another try.
    This time with good result.
    To get baud rate, parity and stop bits from original CDC demo, use this code
    Code:
        BaudRate var long BANKA SYSTEM
        StopBits Var	Byte BANKA SYSTEM ;0=1 stop bit, 2=2 stop bit
        ParityType Var	Byte BANKA SYSTEM
        DataBits Var	Byte BANKA SYSTEM
    Main: ' original code from CDC example
    
        GOSUB GetLineCoding 'get baudrate etc... Should do that regularly and check if anything is changed
     
    
    GetLineCoding:
    asm
     	movlb	high _USBMEMORYADDRESS	; Point to proper bank
    
    	movf	line_coding + dwDTERate, W
    	movwf   BaudRate 
        movf	line_coding + dwDTERate + 1, W
    	movwf   BaudRate + 1
    	movf	line_coding + dwDTERate + 2, W
    	movwf   BaudRate + 2
    	movf	line_coding + dwDTERate + 3, W
        movwf   BaudRate + 3
        
    	movf	line_coding + bCharFormat, W	 
    	movwf   StopBits
    	
    	movf	line_coding + bParityType, W	 
        movwf   ParityType
    
    	movf	line_coding + bDataBits, W	 
    	movwf   DataBits
    endasm
    RETURN

Similar Threads

  1. pic18f driving usb printers
    By ephesus in forum USB
    Replies: 18
    Last Post: - 22nd March 2012, 02:07
  2. USB certification PIC18F
    By Pic2008 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 25th June 2010, 19:37
  3. serial to usb converter
    By nicjo in forum Serial
    Replies: 3
    Last Post: - 17th September 2008, 23:52
  4. FTDI USB to Serial converter chip
    By mwhatley in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 23rd September 2007, 03:30
  5. Serial to USB converter
    By jrt4fun in forum USB
    Replies: 6
    Last Post: - 8th August 2005, 15:14

Posting Permissions

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