cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H7 nucleo USB FS CDC

embvis
Associate III
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
1 ACCEPTED SOLUTION

Accepted Solutions
Marina Brener
Associate III
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

View solution in original post

19 REPLIES 19
Marina Brener
Associate III
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

embvis
Associate III
Posted on November 12, 2017 at 02:34

Its now workingk. Thank you Marina.

Imen.D
ST Employee
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

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
Andrew Ivanov
Associate II
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.

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

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
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

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.

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
Posted on May 08, 2018 at 16:16

Hi Dirk,

Glad it helped!

I need to support a host mode as well as device mode.

How did you connect a usb host side cable to the nucleo board?

Thanks,

Marina