Skip to main content
iguffick
Associate II
September 15, 2008
Question

USB Virtual COM Port - flow control

  • September 15, 2008
  • 4 replies
  • 1127 views
Posted on September 15, 2008 at 23:19

USB Virtual COM Port - flow control

    This topic has been closed for replies.

    4 replies

    iguffick
    iguffickAuthor
    Associate II
    May 17, 2011
    Posted on May 17, 2011 at 12:45

    Thanks, I'll give that a try.

    mark4
    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 12:45

    I added this status check and my virtual com port now works fine with files in the comm program.

    Code:

    void USB_Tx_Byte( u8 *str )

    {

    while (_GetEPTxStatus(ENDP1)==EP_TX_VALID)

    {}

    UserToPMABufferCopy(str, ENDP1_TXADDR, 1); //intent; send ascii[] to usb packet-memory-area

    SetEPTxCount(ENDP1, 1); //intent; tell usb how many bytes to send

    SetEPTxValid(ENDP1); //intent; enable usb tx endpoint for transmission

    }

    For RX, don't issue this command until you handle all the bytes from the current transfer.

    Code:

    SetEPRxValid(ENDP3); // allow another transfer

    iguffick
    iguffickAuthor
    Associate II
    May 17, 2011
    Posted on May 17, 2011 at 12:45

    I'm using the USB Virtual COM Port and noticed that there is no flow control from the PC to USB.

    If you type things into HyperTerminal everything works fine.

    But if you send a text file (a few Kb) then it gets corrupted.

    If the buffer for characters exiting the USART is not empty, then it gets over written by the next USB frame.

    What is the correct way of rejecting/stopping frames if the STM32 buffer is full?

    lanchon
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 12:45

    a while back I posted an stdio redirector via virtual COM that has flow control and fixes some data races.