2011-07-01 12:56 PM
Hello! I did try to use Virtual COM port project from archive STM32_USB-FS-Device_Lib_V3.3.0, loaded from site. But have problem - when MCU do sending ''bytes string'' from MCU to PC with length 0x40, 0x80, 0xC0 - PC didn't receive anything. If MCU do sending 0x3F, 0x41 bytes or other except ''maxlength'' - all is okey, PC will receive bytes with success! One else - If MCU did send ''single string'' with 0x40 bytes length and (after pause) send some else bytes - PC will receive old 0x40 bytes with these some else bytes! Can you are check it on your testboard?
#usb2011-07-04 08:23 AM
Hello Denis,
it seems that 0x40 is Your endpoint buffer size. The host recognizes the end of a transaction when a pakage with ''less than buffer size'' data is received. (This is an USB protocol issue.) If You are sending a multiple of your endpoint buffer size You must send a empty pakage after Your last transaction to show the host that Your transaction is complete now. I think the second problem You mentioned should be cleared with that, too. Kind regards bgl2012-01-07 12:38 PM
Hello!
Big thanks for answer!!! Best solution is changing some in UsbAsyncXfer procedure. It must be looks asuint16_t USB_Tx_length =0; // - move it outside function to save last TX packet data length
void Handle_USBAsynchXfer (void)
{
uint16_t USB_Tx_ptr =0;
if(USB_Tx_State != 1)
{
if (USART_Rx_ptr_out == USART_RX_DATA_SIZE)
{
USART_Rx_ptr_out = 0;
}
if(USART_Rx_ptr_out == USART_Rx_ptr_in)
{
USB_Tx_State = 0;
if(USB_Tx_length == VIRTUAL_COM_PORT_DATA_SIZE) // èñïðàâëÿåì êîñÿê ñ ïîñûëêîé 0x40 áàéòîâ
{ USB_Tx_length =0;
goto SendZeroPacket;
}
return; // transmitt end
}
if(USART_Rx_ptr_out > USART_Rx_ptr_in) /* rollback */
{
USART_Rx_length = USART_RX_DATA_SIZE - USART_Rx_ptr_out;
}
else
{
USART_Rx_length = USART_Rx_ptr_in - USART_Rx_ptr_out;
}
if (USART_Rx_length > VIRTUAL_COM_PORT_DATA_SIZE)
{
USB_Tx_ptr = USART_Rx_ptr_out;
USB_Tx_length = VIRTUAL_COM_PORT_DATA_SIZE;
USART_Rx_ptr_out += VIRTUAL_COM_PORT_DATA_SIZE;
USART_Rx_length -= VIRTUAL_COM_PORT_DATA_SIZE;
}
else
{
USB_Tx_ptr = USART_Rx_ptr_out;
USB_Tx_length = USART_Rx_length;
USART_Rx_ptr_out += USART_Rx_length;
USART_Rx_length = 0;
}
USB_Tx_State = 1;
SendZeroPacket:
USB_SIL_Write(EP1_IN, &USART_Rx_Buffer[USB_Tx_ptr], USB_Tx_length);
}
}