Skip to main content
Visitor II
November 9, 2017
Solved

STM32H7 nucleo USB FS CDC

  • November 9, 2017
  • 7 replies
  • 7870 views
Posted on November 09, 2017 at 10:37

Hi,

I am trying to start with USB CDC on stm32h7. I create new project with CubeMx + STM32Cube_FW_H7_V1.1.0 (cubemx file attached). After compile usb device doesnt appear on the system.

Regards

Mike

#stm32h743 #virtual-comport-stm32 #cdc #stm32h7 #usb-device #usb-fs-cdc
    This topic has been closed for replies.
    Best answer by Marina Brener
    Posted on November 09, 2017 at 16:12

    Hi Mikolaj,

    I had the same problem, this function solved it : 

    HAL_PWREx_EnableUSBVoltageDetector() .

    Please add this function call to usb_device.c file like this.

    void MX_USB_DEVICE_Init(void)

    {

    /* USER CODE BEGIN USB_DEVICE_Init_PreTreatment */

    /* USER CODE END USB_DEVICE_Init_PreTreatment */

    /* Init Device Library,Add Supported Class and Start the library*/

    USBD_Init(&hUsbDeviceFS, &FS_Desc, DEVICE_FS);

    USBD_RegisterClass(&hUsbDeviceFS, &USBD_CDC);

    USBD_CDC_RegisterInterface(&hUsbDeviceFS, &USBD_Interface_fops_FS);

    USBD_Start(&hUsbDeviceFS);

    /* USER CODE BEGIN USB_DEVICE_Init_PostTreatment */

    HAL_PWREx_EnableUSBVoltageDetector();

    /* USER CODE END USB_DEVICE_Init_PostTreatment */

    }

    Hope it helps!

    Marina

    7 replies

    Visitor II
    November 9, 2017
    Posted on November 09, 2017 at 16:12

    Hi Mikolaj,

    I had the same problem, this function solved it : 

    HAL_PWREx_EnableUSBVoltageDetector() .

    Please add this function call to usb_device.c file like this.

    void MX_USB_DEVICE_Init(void)

    {

    /* USER CODE BEGIN USB_DEVICE_Init_PreTreatment */

    /* USER CODE END USB_DEVICE_Init_PreTreatment */

    /* Init Device Library,Add Supported Class and Start the library*/

    USBD_Init(&hUsbDeviceFS, &FS_Desc, DEVICE_FS);

    USBD_RegisterClass(&hUsbDeviceFS, &USBD_CDC);

    USBD_CDC_RegisterInterface(&hUsbDeviceFS, &USBD_Interface_fops_FS);

    USBD_Start(&hUsbDeviceFS);

    /* USER CODE BEGIN USB_DEVICE_Init_PostTreatment */

    HAL_PWREx_EnableUSBVoltageDetector();

    /* USER CODE END USB_DEVICE_Init_PostTreatment */

    }

    Hope it helps!

    Marina

    Visitor II
    May 8, 2018
    Posted on May 08, 2018 at 11:12

    Thank you for sharing! I am working on a recently designed STM32H743II board and faced the same issue! Even the latest CubeMX4.25.0 and STM32H7Cube 1.2 dont fix this issue.

    Next problem I am facing is to detect a USB memory stick attached to the USB HS HOST port using the MSC class. The USBH_Process() is always in the HOST_IDLE state.

    Best regards

    Dirk

    Technical Moderator
    May 8, 2018
    Posted on May 08, 2018 at 11:39

    Hello

    Handzic.Dirk

    ,

    ST team is aware about the issue ofmissing call to HAL_PWREx_EnableUSBVoltageDetector( ) and should fix this limitation in the coming release, but all

    depends on releases planning and expected fixes or new features to embed.

    It should be better to start a new discussion for new issue with more details even if the topic is the same.

    Best Regards,

    Imen.

    embvisAuthor
    Visitor II
    November 12, 2017
    Posted on November 12, 2017 at 02:34

    Its now workingk. Thank you Marina.

    Technical Moderator
    November 16, 2017
    Posted on November 16, 2017 at 15:40

    Hello,

    Thank you to share this issue. I raised it internally to the appropriate team for work and fix it.

    Best Regards

    Imen

    Visitor II
    November 29, 2017
    Posted on November 29, 2017 at 08:34

    May be you know how to resolve, I worked with nucleo144 board (stm32f767) and I had some problem. Windows define board how unkown usb device. But Keil debuger stopped in irq handler 'void OTG_FS_IRQHandler(void)'. May be I dont`t initialize any option.

    Graduate II
    December 11, 2017
    Posted on December 11, 2017 at 18:38

    I'm having this same issue with my nucleo144 (F767) board.

    I get interrupts going to OTG_FS_IRQ_Handler, which calls HAL_PCD_IRQHandler.

    BUT, none of the functions hooked using USBF_Interface_fops_FS are ever called.  CDC_Init_FS never gets called.

    I have been tracing the code for the last week and  the functions get hooked into hpcd-> pData properly, but I can't figure out where the HAL_PCD routines actually call the routines that are pointed at.

    I tried putting in the call to

    HAL_PWREx_EnableUSBVoltageDetector

    , which didn't make sense, 

    but it doesn't seem to exist in F7 HAL version 1.8.0.

    It's like the CDC/PCD connection is broken in 1.8.0.

    Andrei

    Visitor II
    December 12, 2017
    Posted on December 12, 2017 at 21:08

    Hi Andrei,

    I was using this function because the usb voltage on stm32h7 comes from VDD33 voltage level detector.

    So the code is actually:

    void HAL_PWREx_EnableUSBVoltageDetector(void)

    {

      /* Enable the USB voltage detector */

      SET_BIT(PWR->CR3, PWR_CR3_USB33DEN);

    }

    Is stm32f767 has a USB regulator that needs to be enabled?

    0690X00000609CPQAY.png
    Visitor II
    August 16, 2018

    HI, I have similar issue, but

    HAL_PWREx_EnableUSBVoltageDetector() doesn't do the trick for me, my bet is incorrect codebase generated by stm32cubeMX 4.26 + FW 1.3

    Is there anyone who deal with that problem?

    Actually usb33den bit doesn't set after function call, in debugger at least.

    Visitor II
    September 28, 2018

    I am using PB13,PB14,PB15 for USB host connectivity and PF2,PF3 for USB_HOST_PWRON and USB_HOST_OVERCURR using a STMPS2141 to provide power to the host connector. 

    https://www.brotherprintersupportnumber.com/brother-printer-setup/

    Visitor II
    June 7, 2019

    I have same problem with NUCLEO STM32H743ZI Virtual Com Port - I can not open port on PC

    I have Nucleo STM32H743ZI board. I'm using CubeMX HAL (I tried several versions) and TrueStudio. "Virtual COM port" appearances in Windows 10 (I tried default Windows driver and ST driver) but I can not open port. My C# program write me "The parameter is incorrect" when I try open it:

    SerialPort port = new SerialPort("COM8", 9600, Parity.None, 8, StopBits.One);
    port.Open(); // System.IO.IOException: 'The parameter is incorrect.'

    same message writes me program Realterm, PuTTY do nothing and "Tera Term" program works correct - I can send and receive data to my MCU program.

    May anyone know what is it?

    In my C# program and in terminal programs I use same parameters

    Visitor II
    June 7, 2019

    STM32H743ZI USB FullSpeed Virtual Com Port: 'Com port parameter is incorrect'

    For data exchange with MCU on Windows 10 I use C function: fopen("COM6", "r+"), fwrite, fgetc, fclose, - without COM port parameters and it's work. But if I use C++ Qt or C# libraries, when I try to open the COM port I catch exception 'The parameter is incorrect'. Same exception I catch in PuTTY and RealTerm programs. I tried setting various parameters. I think USB device cannot accept COM port parameters from PC. I used Nucleo and my board with same result.

    I use CubeMX 5.2.1 and FW 1.4.0. If I use CubeMX 4.27.0 and FW 1.3.2 PC is not found USB device.

    Also USB description has error in field bDeviceSubClass in FW 1.4.0 and FW 1.3.2.

    Microsoft UsbView program:

         ===>Device Descriptor<===

    bLength:             0x12

    bDescriptorType:         0x01

    bcdUSB:             0x0200

    bDeviceClass:           0x02 -> This is a Communication Device

    bDeviceSubClass:         0x02

    *!*ERROR: bDeviceSubClass of 2 is invalid

    bDeviceProtocol:         0x00

    bMaxPacketSize0:         0x40 = (64) Bytes

    idVendor:            0x0483 = STMicroelectronics

    idProduct:           0x5740

    bcdDevice:           0x0200

    iManufacturer:          0x01

       English (United States) "STMicroelectronics"

    iProduct:             0x02

       English (United States) "STM32 Virtual ComPort"

    iSerialNumber:          0x03

       English (United States) "383A34463137"

    bNumConfigurations:        0x01

    Visitor II
    June 7, 2019

     ---===>Open Pipes<===---

     ===>Endpoint Descriptor<===

    bLength:              0x07

    bDescriptorType:          0x05

    bEndpointAddress:         0x82 -> Direction: IN - EndpointID: 2

    bmAttributes:           0x03 -> Interrupt Transfer Type

    wMaxPacketSize:         0x0008 = 0x08 bytes

    bInterval:             0x10

     ===>Endpoint Descriptor<===

    bLength:              0x07

    bDescriptorType:          0x05

    bEndpointAddress:         0x01 -> Direction: OUT - EndpointID: 1

    bmAttributes:           0x02 -> Bulk Transfer Type

    wMaxPacketSize:         0x0040 = 0x40 bytes

    bInterval:             0x00

     ===>Endpoint Descriptor<===

    bLength:              0x07

    bDescriptorType:          0x05

    bEndpointAddress:         0x81 -> Direction: IN - EndpointID: 1

    bmAttributes:           0x02 -> Bulk Transfer Type

    wMaxPacketSize:         0x0040 = 0x40 bytes

    bInterval:             0x00

      ---===>Full Configuration Descriptor<===---

     ===>Configuration Descriptor<===

    bLength:              0x09

    bDescriptorType:          0x02

    wTotalLength:          0x0043 -> Validated

    bNumInterfaces:          0x02

    bConfigurationValue:        0x01

    iConfiguration:          0x00

    bmAttributes:           0xC0 -> Self Powered

    MaxPower:             0x32 = 100 mA

     ===>Interface Descriptor<===

    bLength:              0x09

    bDescriptorType:          0x04

    bInterfaceNumber:         0x00

    bAlternateSetting:         0x00

    bNumEndpoints:           0x01

    bInterfaceClass:          0x02 -> This is Communications (CDC Control) USB Device Interface Class

    bInterfaceSubClass:        0x02

    bInterfaceProtocol:        0x01

    iInterface:            0x00

     -> This is a Communications (CDC Control) USB Device Interface Class

     ===>Descriptor Hex Dump<===

    bLength:              0x05

    bDescriptorType:          0x24

    05 24 00 10 01 

     -> This is a Communications (CDC Control) USB Device Interface Class

     ===>Descriptor Hex Dump<===

    bLength:              0x05

    bDescriptorType:          0x24

    05 24 01 00 01 

     -> This is a Communications (CDC Control) USB Device Interface Class

     ===>Descriptor Hex Dump<===

    bLength:              0x04

    bDescriptorType:          0x24

    04 24 02 02 

     -> This is a Communications (CDC Control) USB Device Interface Class

     ===>Descriptor Hex Dump<===

    bLength:              0x05

    bDescriptorType:          0x24

    05 24 06 00 01 

     ===>Endpoint Descriptor<===

    bLength:              0x07

    bDescriptorType:          0x05

    bEndpointAddress:         0x82 -> Direction: IN - EndpointID: 2

    bmAttributes:           0x03 -> Interrupt Transfer Type

    wMaxPacketSize:         0x0008 = 0x08 bytes

    bInterval:             0x10

     ===>Interface Descriptor<===

    bLength:              0x09

    bDescriptorType:          0x04

    bInterfaceNumber:         0x01

    bAlternateSetting:         0x00

    bNumEndpoints:           0x02

    bInterfaceClass:          0x0A -> This is a CDC Data USB Device Interface Class

    bInterfaceSubClass:        0x00

    bInterfaceProtocol:        0x00

    iInterface:            0x00

     ===>Endpoint Descriptor<===

    bLength:              0x07

    bDescriptorType:          0x05

    bEndpointAddress:         0x01 -> Direction: OUT - EndpointID: 1

    bmAttributes:           0x02 -> Bulk Transfer Type

    wMaxPacketSize:         0x0040 = 0x40 bytes

    bInterval:             0x00

     ===>Endpoint Descriptor<===

    bLength:              0x07

    bDescriptorType:          0x05

    bEndpointAddress:         0x81 -> Direction: IN - EndpointID: 1

    bmAttributes:           0x02 -> Bulk Transfer Type

    wMaxPacketSize:         0x0040 = 0x40 bytes

    bInterval:             0x00