cancel
Showing results for 
Search instead for 
Did you mean: 

USB Virtual COM Port - flow control

iguffick
Associate II
Posted on September 15, 2008 at 23:19

USB Virtual COM Port - flow control

4 REPLIES 4
iguffick
Associate II
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?

mark4
Associate II
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
Associate II
Posted on May 17, 2011 at 12:45

Thanks, I'll give that a try.

lanchon
Associate III
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.