AnsweredAssumed Answered

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

Question asked by June Zhou on Sep 28, 2017
Latest reply on Sep 28, 2017 by Clive One

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

Attachments

Outcomes