STMicroelectronics Virtual COM Port problem send big data
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2014-05-19 1:52 PM
Posted on May 19, 2014 at 22:52
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?
This discussion is locked. Please start a new topic to ask your question.
3 REPLIES 3
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2014-05-20 1:14 AM
Posted on May 20, 2014 at 10:14
''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()Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2014-05-20 3:02 AM
Posted on May 20, 2014 at 12:02
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?Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2014-05-20 3:19 AM
Posted on May 20, 2014 at 12:19
''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 ); }