cancel
Showing results for 
Search instead for 
Did you mean: 

STM32Cube USB VCP on STM32F103C8 crash problem

gmgunderground
Associate II
Posted on November 19, 2015 at 12:21

Hi, I have generated a basic project with STM32Cube. the 1st step is to make USB working as COM Port. I have made some tests and the communication from STM32 and PC is working I can send data, but if I try to send some bytes from PC to STM32 the device make a rest and windows say device not recognized. The code I have used is the basic generated by STM32Cube, no custom code (only for sending byte is custom) why as is the generated code doesn't work? I have attached some screenshots of STM32Cube. Also why if I attach the device the PC recognize two serial ports, one working (COM7) one not working (COM6)?

Best regards

Gian

#usb #cdc #cdc #stm32l1 #stm32cube
3 REPLIES 3
gmgunderground
Associate II
Posted on November 19, 2015 at 18:04

Solved, the solution for everyone and a suggestion to STM32Cube team

Original function:

int8_t CDC_Receive_FS (uint8_t* Buf, uint32_t *Len)
{
/* USER CODE BEGIN 6 */
return (USBD_OK);
/* USER CODE END 6 */
}

Modified function

int8_t CDC_Receive_FS (uint8_t* Buf, uint32_t *Len)
{
/* USER CODE BEGIN 6 */
USBD_CDC_ReceivePacket(&hUsbDeviceFS);
return (USBD_OK);
/* USER CODE END 6 */
}

without USBD_CDC_ReceivePacket(&hUsbDeviceFS); after fiew bytes all is crashing
yeap101
Associate
Posted on December 03, 2015 at 04:09

Hello Gian,

I have same problem with you. After I do the solution , it's not work.

I am using STM32L151CBT6 , my custom board. The USB CDC was worked with 

example of STM32_USB-FS-Device_Lib_V3.4.0.

Do you modify other code after CUBE generated ?

Regards

Yeap

Amel NASRI
ST Employee
Posted on December 03, 2015 at 14:47

Hi wu.yeap,

Is your device successfully enumerated? If no, try to increase heap and stack sizes.

-Mayla-

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.