Skip to main content
Visitor II
February 3, 2018
Question

stm32f4 multi instance usb cdc device

  • February 3, 2018
  • 4 replies
  • 3551 views
Posted on February 03, 2018 at 14:54

For a USB CDC device application I use STM32CubeF4.

It works very well now.

Now I need a second CDC channel, which paralel the 1st CDC transmits a data stream to the host.

How do I create a second USB CDC instance with Cube and how is it used?

I have set the parameter 'USBD_MAX_NUM_INTERFACES (Maximum number of supported interfaces)' to 2 in Cube, but this has changed nothing in the generated files except for the '&sharpdefine USBD_MAX_NUM_INTERFACES 2' in usb_conf.h.

USBD_MAX_NUM_INTERFACES is used only once in the file usbd_ctlreq.c throughout the project.

Is this even possible with Cube / HAL or do I have to venture the new adventure and switch to the ARM middleware library?

There is in the description 'The USB Component allows multiple instances of the CDC class.'

In the STM Cube documentation I did not find any indication that multi instanc CDCe is supported or not.

#cube-stm32f4-multi-instance-usb-cdc-device #stm32f4-multi-instance-usb-cdc-device*
    This topic has been closed for replies.

    4 replies

    Graduate II
    August 10, 2018

    Sorry, bumping old zombie unanswered questions off my feed

    Visitor II
    November 15, 2018

    I have the same question. If I change the number USBD_MAX_NUM_INTERFACES from 1 to 2 I still have one /dev/ttyACM0. Is it possible to run more then one with different product identifiers ? Who from ST can support this topic ?

    Visitor II
    September 5, 2022

    Same problem for me today with a STM32L072 device...

    Super User
    September 5, 2022

    @MSoli.2​ IIRC this is a Cube startup generator deficiency. To have two or more instances of same device class you need to manually add & initialize the 2nd class "object" (struct).

    Visitor II
    September 6, 2022

    I had seen that the post was particularly old and I was hoping this aspect had been improved.

    Do you have an example to suggest that it is based on the code generated by CubeMX?

    Graduate II
    January 19, 2024

    Hi,

    it is a shame that CubeMX does not support a combination of several device classes. After one day of searching examples i found a "software pack" for CubeMX:

    alambe94/I-CUBE-USBD-Composite: Create STM32 USB Composite devices with ease. (github.com)

    ST, please support this project and promote it, so we all can save lifetime!

     

    MKing_0-1705645332984.png

     

    I use:

    CubeMX 6.10.0

    CubeIDE 1.14.0

    Processor: STM32F407VGT