Transmit data through CDC VCP Failed error
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:
- Changed min heap size = 0x2000 and min stack size = 0x2000 (I tried several values)
- downloaded the VCP driver even though I am using win10.
- The global interrupt is enabled.
- set get Line coding function:
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.
