X893

STM32F103 Dual CDC

Dual CDC for STM32F103.

 Test with Maple RET6 board.

Use USART1 and USART2 to send/receive data.

15 comment(s) so far

  1. STM32F103 Dual CDC is a great example. But there is a bug in usb_conf.h Line 56:

    You must define the Endpoint 6 Rx address to:

    #define ENDP6_RXADDR (0x1C0)

    With 0x1D0 there is a buffer overflow when receiving usb pakets with more than 48 Bytes (The highest address is 0x1FF, with max packet size 64 Bytes the start address must be 0x1C0).

  2. Thanks. I add to source

  3. Hi Tsuneo!

    Thanks your example,I'm using your STM32F103 Dual CDC,my mcu is STM32F103C8T6,and connected Pin RX and Pin TX together,when set BPS<=9600bps,your example works well,when set BPS>=1440bps,miss some datas,I could found that USB->VCOM TX and VCOM TX -> VCOM RX are right,the problem may be on VCOM->usb endpoind,please give me some advises.

    Thanks!

  4. Hi Scanli,

    this example very simple. As variant you can implement ring buffer for USART data in/out.

  5. hi

    I'm trying to make usb composite device that combine Hid+cdc classes on STM32F103 WITH USB_FS_library .can you please help me

  6. Hi,

    you can see CMSIS-DAP adapter for STM32. It contain HID+CDC with USB library. Remove debugger processing (only use HID part). CDC part use USART and USB-CDC.

    akb77.com/.../cmsis-dap-adapt

  7. Hi

    i download file CMSIS_DAP_STM32.rar and i compile it but there are many errors .can i use the dual cdc program to do usb composite by replace one cdc with HID class in the descriptor file ?

  8. Hi

    i download file CMSIS_DAP_STM32.rar and i compile it but there are many errors .can i use the dual cdc program to do usb composite by replace one cdc with HID class in the descriptor file ?

  9. Download from gitgub github.com/.../CMSIS-DAP Firmware\STM32\CMSIS_DAP.uvproj

    I use Keil MDK 4.72

  10. usb composite (hid+cdc+IAD )

    Hello everyone,

    I'm trying to make a USB composite device working both CDC and HID, to work as a virtual com port and as HID device at the same time.

    I combine both CDC and HID classes on a STM32F103 discovery board with the USB-FS library.

    The device is detected by the host but with a yellow warning sign code(10)

    DESCRIPTOR FILE

    #include "usb_lib.h"

    #include "usb_desc.h"

    /* USB Standard Device Descriptor */

    const uint8_t Virtual_Com_Port_DeviceDescriptor[] =

    {

    0x12, /* bLength */

    USB_DEVICE_DESCRIPTOR_TYPE, /* bDescriptorType */

    0x00,

    0x02, /* bcdUSB = 2.00 */

    0xEF, /* bDeviceClass: IAD */

    0x02, /* bDeviceSubClass */

    0x01, /* bDeviceProtocol */

    0x40, /* bMaxPacketSize0 */

    0xEB,

    0x33, /* idVendor = 0x03EB */

    0x33,

    0x66, /* idProduct = 0x6133 */

    0x00,

    0x02, /* bcdDevice = 2.00 */

    1, /* Index of string descriptor describing manufacturer */

    2, /* Index of string descriptor describing product */

    3, /* Index of string descriptor describing the device's serial number */

    0x01 /* bNumConfigurations */

    };

    const uint8_t Virtual_Com_Port_ConfigDescriptor[] =

    {

    /*Configuation Descriptor*/

    0x09, /* bLength: Configuation Descriptor size */

    USB_CONFIGURATION_DESCRIPTOR_TYPE, /* bDescriptorType: Configuration */

    VIRTUAL_COM_PORT_SIZ_CONFIG_DESC, /* wTotalLength:no of returned bytes */

    0x00,

    // 0x04, /* bNumInterfaces: 4 interface */

    0x03, /* bNumInterfaces: 3 interface */

    0x01, /* bConfigurationValue: Configuration value */

    0x00, /* iConfiguration: Index of string descriptor describing the configuration */

    0xC0, /* bmAttributes: self powered */

    0x32, /* MaxPower 100 mA */

    /************** Descriptor of Custom HID interface ****************/

    /* 09 */

    0x09, /* bLength: Interface Descriptor size */

    USB_INTERFACE_DESCRIPTOR_TYPE,/* bDescriptorType: Interface descriptor type */

    0x00, /* bInterfaceNumber: Number of Interface */

    0x00, /* bAlternateSetting: Alternate setting */

    0x02, /* bNumEndpoints */

    0x03, /* bInterfaceClass: HID */

    0x00, /* bInterfaceSubClass : 1=BOOT, 0=no boot */

    0x00, /* nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse */

    0, /* iInterface: Index of string descriptor */

    /******************** Descriptor of Custom HID HID ********************/

    /* 18 */

    0x09, /* bLength: HID Descriptor size */

    HID_DESCRIPTOR_TYPE, /* bDescriptorType: HID */

    //0x10, /* bcdHID: HID Class Spec release number */

    0x00, /* bcdHID: HID Class Spec release number */

    0x01,

    0x00, /* bCountryCode: Hardware target country */

    0x01, /* bNumDescriptors: Number of HID class descriptors to follow */

    0x22, /* bDescriptorType */

    CUSTOMHID_SIZ_REPORT_DESC,/* wItemLength: Total length of Report descriptor */

    0x00,

    /******************** Descriptor of Custom HID endpoints ******************/

    /* 27 */

    0x07, /* bLength: Endpoint Descriptor size */

    USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType: */

    0x81, /* bEndpointAddress: Endpoint Address (IN1) */

    // 0x84, /* bEndpointAddress: Endpoint Address (IN4) */

    0x03, /* bmAttributes: Interrupt endpoint */

    // 0x02, /* wMaxPacketSize: 2 Bytes max */

    0

  11. Yiu can see woorking CDC+HID example in CMSIsS--DAP port fot STM32

    akb77.com/.../cmsis-dap-adapt

  12. i saw it but it isn't work i didn't find the file contian the descriptor of usb composite. there is my probleme know .i took the exemple of dual cdc and i delete one of interface cdc and i add the part hid in the descriptor with (IAD) interface.The device is detected by the host but with a yellow warning sign code(10).i need just how configure the descriptor file and if there are functions i must add to the discriptor file to work .give me exemple of descriptor of cdc +hid.can you please help me? i must finish this project very quickly .thanks for your help X893 :)))))

  13. I use this configuration file for CDC+HID

    github.com/.../usb_config.c

  14. scanli

    Wednesday, June 26 2013

    Hi Tsuneo!

    Thanks your example,I'm using your STM32F103 Dual CDC,my mcu is STM32F103C8T6,and connected Pin RX and Pin TX together,when set BPS<=9600bps,your example works well,when set BPS>=1440bps,miss some datas,I could found that USB->VCOM TX and VCOM TX -> VCOM RX are right,the problem may be on VCOM->usb endpoind,please give me some advises.

    Hello,

    I am using your example,too. As scanli I have problem like scanli. usb to usart is working well but usart to usb datas loss or repeat, for example as I send "123456789" at terminal it comes like "12356789" or "1234556789". How can I solve this problem? Thank you.

  15. Hi Sir,

    I have successfully test dual cdc on my win 7 environment. I want to modified it to three or more virtual com port. but I have no clue about the windows driver . Could you please share some material to develop custom windows driver? especially on how to develop virtual serial port windows driver. Thank you

    Best Regards,

    Yudhi

Post your comment

Thanks for your comments

  • Comment

Github
Bitbucket
Codeplex
SF.net

Subscribe to x893 blog Subscribe to x893 blog