cancel
Showing results for 
Search instead for 
Did you mean: 

Computer will not recognize our USB CDC Port if sending characters lager than 12

June Zhou
Associate II
Posted on September 28, 2017 at 19:33

Hello,

I use STM32F413ZG MCU, USB as communication Device Class(Virtual Port Com) to transmit data to computer(Master). I do not connect VBUS line, only use USB DPand DM. the USB canle is type C.

When our device power on and USB cable plugged in between them, the computer can find USB serial device(COM6). And then I use hyper terminal to send data.

If sending characters lager than 12,

i.e. 'AT+SETTINCODE'from computer to our device, our device was able to got these character: the receiving function static int8_t CDC_Receive_FS (uint8_t* Buf, uint32_t *Len) still works, 

our device still 

can get Buf [ ] = ' AT+SETTINCODE'. But, at this time, unplugged USB cable from computer, and then plunged it in again, the computer cannot find USB serial Port(COM6) and will show error ' The last USB device you connected to this computer malfunction and Windows dose not not recognized it'.(see attached picture)

But If sending characters less than 13, i.e. 'OK' or 'AT+SGSN:TR24',  everything is good: Buf ='AT+SGSN:TR24'. our device can got these characters, and then, I took USB cable out  and plugged USB in again, the computer can recognized USB Port (COM6). 

Do you some suggestions for solving this problem? Thanks a lot!

Note: The USB initial codes like below

USBD_StatusTypeDef USBD_LL_Init (USBD_HandleTypeDef *pdev)

{

/* Init USB_IP */

if (pdev->id == DEVICE_FS) {

/* Link The driver to the stack */

hpcd_USB_OTG_FS.pData = pdev;

pdev->pData = &hpcd_USB_OTG_FS;

hpcd_USB_OTG_FS.Instance = USB_OTG_FS;

hpcd_USB_OTG_FS.Init.dev_endpoints = 6;

hpcd_USB_OTG_FS.Init.speed = PCD_SPEED_FULL;

hpcd_USB_OTG_FS.Init.dma_enable = DISABLE;

hpcd_USB_OTG_FS.Init.ep0_mps = DEP0CTL_MPS_64;

hpcd_USB_OTG_FS.Init.phy_itface = PCD_PHY_EMBEDDED;

hpcd_USB_OTG_FS.Init.Sof_enable = DISABLE;

hpcd_USB_OTG_FS.Init.low_power_enable = DISABLE;

hpcd_USB_OTG_FS.Init.lpm_enable = DISABLE;

hpcd_USB_OTG_FS.Init.battery_charging_enable = DISABLE;

hpcd_USB_OTG_FS.Init.vbus_sensing_enable = DISABLE; //ENABLE;

hpcd_USB_OTG_FS.Init.use_dedicated_ep1 = DISABLE;

if (HAL_PCD_Init(&hpcd_USB_OTG_FS) != HAL_OK)

{

Error_Handler();

}

HAL_PCDEx_SetRxFiFo(&hpcd_USB_OTG_FS, 0x80);

HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 0, 0x40);

HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 1, 0x80);

}

return USBD_OK;

}

Thanks and looking forward your help !

June

1 REPLY 1
Posted on September 28, 2017 at 21:10

>>Do you some suggestions for solving this problem?

Look at the code that handles the reception of that data. Output real-time telemetry via a serial port so USB can run without delay, and understand the flow of your code. Add a Hard Fault Handler to see if that gets triggered.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..