2022-09-21 12:07 AM
I am trying transmit data using CDC(virtual port) in NUCLEO-H743Zi2, but I am getting this error when I plug in my VCP port to my pc (Unknown USB Device (Device Descriptor Request Failed)), I could not find a way to fix it.
My hardware settings:
MCU speed set to MAX(480Mhz)
USB_OTG_FS : Device Only | VBUS sensing | enabled Activate SOF
USB_Device : CDC(VPC).
my transmission code:
/* USER CODE BEGIN PD */
#include "main.h"
#include "usb_device.h"
#include "usbd_cdc_if.h"
#include "string.h"
/* USER CODE END PD */
char *data = "Hello there";
int main(void)
{
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* Configure the system clock */
SystemClock_Config();
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_USART3_UART_Init();
MX_DMA_Init();
MX_SPI1_Init();
MX_USB_DEVICE_Init();
/* Infinite loop */
while (1) {
/* USER CODE END WHILE */
CDC_Transmit_FS((uint8_t *) data , strlen(data));
HAL_Delay (1000);
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}
The debugging steps I followed:
USBD_CDC_LineCodingTypeDef LineCoding = {
115200, /* baud rate */
0x00, /* stop bits-1 */
0x00, /* parity - none */
0x08 /* nb. of bits 8 */
};
static int8_t CDC_Control_FS(uint8_t cmd, uint8_t* pbuf, uint16_t length)
{
switch(cmd)
{
case CDC_SET_LINE_CODING:
LineCoding.bitrate = (uint32_t) (pbuf[0] | (pbuf[1] << 8) |
(pbuf[2] << 16) | (pbuf[3] << 24));
LineCoding.format = pbuf[4];
LineCoding.paritytype = pbuf[5];
LineCoding.datatype = pbuf[6];
break;
case CDC_GET_LINE_CODING:
pbuf[0] = (uint8_t) (LineCoding.bitrate);
pbuf[1] = (uint8_t) (LineCoding.bitrate >> 8);
pbuf[2] = (uint8_t) (LineCoding.bitrate >> 16);
pbuf[3] = (uint8_t) (LineCoding.bitrate >> 24);
pbuf[4] = LineCoding.format;
pbuf[5] = LineCoding.paritytype;
pbuf[6] = LineCoding.datatype;
break;
...
}
return (USBD_OK);
/* USER CODE END 5 */
}
But still I am getting (Unknown USB Device (Device Descriptor Request Failed) before running the code and after.
2022-09-21 02:41 AM
Hello @AElta.1
Do you have drivers installed STM32 Virtual COM Port Driver ?
I advise you to follow this FAQ: USB device not recognized, it may help you:
You may get inspired from CDC_Standalone examples within STM32H7 MCU package, which can help you to develop your application:
\STM32Cube_FW_H7_V1.10.0\Projects\STM32H743I-EVAL\Applications\USB_Device\CDC_Standalone\
Note: When DMA is used, the MX_DMA_Init shall always be called before any other peripheral initialization. Please refer to this post.
Please keep me informed if you still need help.
If my answer fully solved your issue, please mark it as best by clicking on the "Select as Best" button. This will help other users find this solution more quickly.
Imen
2022-09-22 12:39 AM
hi I tried what u suggested but I am sill facing the same issue
2022-09-22 07:37 AM
Check if USB_OTG_FS_DP and USB_OTG_FS_DM wires are swapped.
2022-09-23 01:14 AM
I thought using Nucleo-H743ZI2 will connect the USB_OTG_FS pin to USB automatically
Even though I checked and no wrong connections.
2022-10-03 05:34 AM
Hi @AElta.1 ,
Please check these FAQs:
Imen