2014-09-23 09:59 AM
Hello!
I'm using the USB driver that is provided by STM32CubeMX 4.3.0. I want to use the CDC implemantation for virtual COM port communication between STM32F401CB and a PC. But I'm facing mainly two problems: 1.) It is not possible to send less than 64 bytes via the CDC driver. In this case only one transmission is successfull. Why is this not possible? How to adopt the code to enable one byte transmissions as well? 2.) How to know if the transmission has been completed? I'm calling CDC_Transmit_FS(...) for sending data, but can't find any callback / interrupt that will be called when the PC has received the data. So in this case I don't know when I can start the next transmission cycle. Thanks for any help! Regards, Thomas2014-09-26 04:36 AM
Hi Thomas,
Could you provide a little more information about the issue you’re experiencing? Can you provide the usbd_cdc_interface.c, usbd_conf.c and main.c source files? What environment are you using? That would help more easily figure out where a problem could be.Regards,Heisenberg.2014-09-29 02:08 AM
Hello!
Attached you find the relevant files. The main.c has been adopted and only shows the relevant parts. The transmission using CDC_Transmit_FS(...) only works once, if I send just a few bytes via USB. TxState is never reset to 0 again, so USBD_CDC_TransmitPacket(...) always returns busy for subsequent calls of CDC_Transmit_FS(...). If I use larger packets to transmit there is no problem. If I set hcdc->TxState = 0; in usbd_cdc.c line 850 it works, but in this case there must be a delay between subsequent calls of CDC_Transmit_FS(...). So this is just an ugly workaround... Thanks for your help! Regards, Thomas ________________ Attachments : main.c : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I13r&d=%2Fa%2F0X0000000bhb%2FtNnm52IUu7HeJUYxg3qE4.fxxWWniLJp88OvL1bhKMw&asPdf=falseusbd_cdc.c : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I13h&d=%2Fa%2F0X0000000bhc%2FWDoiHsZbK1N0Pq8cx13f57lqmrYccga2r1my30gPIpY&asPdf=falseusbd_cdc_if.c : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I13Z&d=%2Fa%2F0X0000000bhZ%2FFvgYi9mfAtpch9XwV5mfSkv7Yuyy0FkNmmZtWghibfk&asPdf=falseusbd_conf.c : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I0xR&d=%2Fa%2F0X0000000bhX%2FgIti23adJvNF6kj7iPb_c45ovsano9vDOwzgGHT3f1A&asPdf=false2014-10-15 04:10 AM
Dear Thomas,
Regarding your implementation:while(1)
{ CDC_Transmit_FS(buf, strlen(hello));
delay(500);
}