2014-05-19 01:52 PM
Hi
I made VCP from ST sample on ST32F405 (STM32_USB-Host-Device_Lib_V2.1.0 & DriverVer=04/25/2010,1.3.1) When I send data from CPU to PC less than 64 byte, all work fine. I have 2 problems: 1) When I try send data from MCU to PC more than 64 byte, then some times data lost. 2) When send data = 64,or 128, or 192... ect. bytes, then data not come to PC (as I understand need zlp) VCP driver from ST have bugs? Somebody know how solved this problems?2014-05-20 01:14 AM
''STM32_USB-Host-Device_Lib_V2.1.0''
Do you mean the USB OTG library? http://www.st.com/web/en/catalog/tools/FM147/CL1794/SC961/SS1743/PF257882 ''I have 2 problems: 1) When I try send data from MCU to PC more than 64 byte, then some times data lost. 2) When send data = 64,or 128, or 192... ect. bytes, then data not come to PC VCP driver from ST have bugs? Somebody know how solved this problems?'' No exactly a bug - just really bad example/implementation. It is all to do with the array APP_Rx_Buffer[] and 'pointer' APP_Rx_ptr_in You put your data into these and hope it gets sent. The actual sending is done in usbd_cdc_core.c Find where these variables are used and how the send (to PC) works with these variables and you should be able to construct a better function for sending : USBDataTx()2014-05-20 03:02 AM
Hi sung.chen_chung
Thanks for answer. Yep, I try send data that: //every 1ms loading 650 byte for( i = 0; i < 650; i++ ) { APP_Rx_Buffer[APP_Rx_ptr_in++] = i; if(APP_Rx_ptr_in == APP_RX_DATA_SIZE) {APP_Rx_ptr_in = 0;} } and this work not stable Can you show me your construct of sending data, if you have it? How I can understand that data which I load in bufer left out to PC, and ready accept new data? Maybe have some callback functions of transfer is complete or flag?2014-05-20 03:19 AM
''Yep, I try send data that:''
Never access these variables outside of the USB driver! ''Can you show me your construct of sending data, if you have it? '' It is pretty much the same as the example code : uint16_t USBDataTx( uint8_t* Buf, uint32_t Len ) { uint32_t i; USB_DisableInterrupt( true ); for( i = 0; i < Len; i++ ) { /* push data into transfer buffer */ APP_Rx_Buffer[APP_Rx_ptr_in] = Buf[i] ; /* increase pointer value */ APP_Rx_ptr_in++; /* add mask value */ // if( (64 == Len) && (i == 63) ) // { // APP_Rx_Buffer[APP_Rx_ptr_in] = 0x00 ; // APP_Rx_ptr_in++; // } /* To avoid buffer overflow */ if( APP_Rx_ptr_in == APP_RX_DATA_SIZE ) { APP_Rx_ptr_in = 0; } } USB_DisableInterrupt( false ); return( USBD_OK ); }