2014-12-16 09:25 AM
I have used CubeMX to generate the USB CDC driver. I connect my board to a computer and the device manager recognize it as: ''STMicroelectronics Virtual COM Port (COM15)'', but it has a error message: ''This device cannot start. (Code 10)''.
I have never worked with USB drivers before and do not know where to start to be able to solve this problem.Any ideas? #usb #cdc #vcp #usb #cdc2014-12-16 09:37 AM
As I recall it was quite sensitive to the correct 32-bit or 64-bit driver being installed, so let's start there.
What version of Windows are you using? What version of the driver are you using? Is this with an ST EVAL board, or some custom board?2014-12-16 09:49 AM
Win7 64-bit. I installed the 64-bit driver as explained in the readme.txt provided with the virtual com port driver.
It is a custom board.2014-12-16 01:38 PM
Find the line in your startup file for stack size. It is probably the folowing:
Stack_Size EQU 0x00000400 Change the value to 0x00004000 Find the line for the heap size in the same file. It is probably the following: Heap_Size EQU 0x00000200 Change the value to 0x00002000I came across the same problem recently, and this resolved it.
I have used CubeMX to generate the USB CDC driver. I connect my board to a computer and the device manager recognize it as: ''STMicroelectronics Virtual COM Port (COM15)'', but it has a error message: ''This device cannot start. (Code 10)''.
I have never worked with USB drivers before and do not know where to start to be able to solve this problem. Any ideas?2014-12-17 12:46 AM
You are correct! The problem described was solved by increasing the stack and heap size as you said. Thank you!
I still can not send or receive data, but Windows now says the device is working properly. I tried setting the receive and transmit buffers and continuously send a message like shown below, but I do not receive anything. Since you did this recently, maybe you have some suggestion?#include ''stm32f4xx_hal.h''
#include ''gpio.h''
#include ''usb_device.h''
#include ''usbd_cdc_if.h''
#define USB_TX_BUFFER_SIZE 100
#define USB_RX_BUFFER_SIZE 100
uint8_t usbCdcTxBuffer[USB_TX_BUFFER_SIZE];
uint8_t usbCdcRxBuffer[USB_RX_BUFFER_SIZE];
void 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_USB_DEVICE_Init();
//Set USB Tx buffer.
USBD_CDC_SetTxBuffer(&hUsbDeviceFS, &usbCdcTxBuffer[0], USB_TX_BUFFER_SIZE);
//Set USB Rx buffer.
USBD_CDC_SetRxBuffer(&hUsbDeviceFS, &usbCdcRxBuffer[0]);
while(1)
{
HAL_Delay(1000);
USBD_CDC_TransmitPacket(&hUsbDeviceFS);
}
}
void SystemClock_Config(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct;
RCC_ClkInitTypeDef RCC_ClkInitStruct;
RCC_PeriphCLKInitTypeDef PeriphClkInitStruct;
__PWR_CLK_ENABLE();
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI|RCC_OSCILLATORTYPE_HSE
|RCC_OSCILLATORTYPE_LSE;
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
RCC_OscInitStruct.LSEState = RCC_LSE_ON;
RCC_OscInitStruct.LSIState = RCC_LSI_ON;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
RCC_OscInitStruct.PLL.PLLM = 8;
RCC_OscInitStruct.PLL.PLLN = 336;
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
RCC_OscInitStruct.PLL.PLLQ = 7;
HAL_RCC_OscConfig(&RCC_OscInitStruct);
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK|RCC_CLOCKTYPE_PCLK1
|RCC_CLOCKTYPE_PCLK2;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;
HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5);
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_RTC;
PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSE;
HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct);
HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_PLLCLK, RCC_MCODIV_2);
}
2014-12-17 04:06 PM
In your example, I don't see where you load anything into the buffer to transmit. Not sure if its happening somewhere else that is not shown.
The base code I started out from had routines in usbd_cdc_if.c. On the receive side, I'd wind up in CDC_Receive whenever a new character came in. I then put some code in to extract the contents of the buffer. There is also a CDC_Transmit function that sends data. Not 100% sure this is how to hook everything together, but its working, so I'm just going with it. :)2015-01-15 05:53 AM
Let me ask you something knapht.fnatt
Your device ''Virtual COM Port STMicroelectronics (COM15)''was in error, but when you connect the USB cable its corrected firmware(heap and stack size) this device started to work?Fixed the error?Thanks!!!2017-10-27 06:15 AM
I am also getting this code 10 error on windows 7, what is the solution?
2018-04-19 03:46 AM
,
,
Hi, See this video
,
Helps youhttps://www.youtube.com/watch?v=4iSRUcb9GWM
,OR
Change the value of the ,
♯ define CDC_DATA_HS_MAX_PACKET_SIZE ,512 , ,// 512 ->,256
entry to the usbd_cdc.h library to 256