Skip to main content
zekeriya
Associate III
December 6, 2016
Question

CubeMx, STM32F103VC, USB-VCP

  • December 6, 2016
  • 3 replies
  • 912 views
Posted on December 06, 2016 at 18:24

With the code generated with CubeMX, the USB virtual com port connection on the STM32F103VC processor is very problematic on Windows.

Exclamation marks are very common in the device manager.

With the method I learned in the forum, I was able to prevent the problem that occurred after the reset.

I added a delay for this after the reset.

int main(void)

{

/* USER CODE BEGIN 1 */

/* USER CODE END 1 */

/* MCU

Configuration----------------------------------------------------------*/

/* 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_USART1_UART_Init();

MX_SPI2_Init();

MX_WWDG_Init();

MX_USB_DEVICE_Init();

/* USER CODE BEGIN 2 */

I2C_Configuration();

loadDefaults();

/* USER CODE END 2 */

/* Infinite loop */

/* USER CODE BEGIN WHILE */

HAL_Delay(1000); //CORRECTION FOR AFTER RESET STATE, USB CABLE IS PLUGGED

HAL_WWDG_Start(&hwwdg);

while (1){

If the problem occurred after the USB cable was disconnected and plugged (exclamation mark in the Windows device manager), I could prevent it with a delay added to the USBD_CDC_DeInit function.

However, this change is lost when CubeMX generates code again.

static uint8_t USBD_CDC_DeInit (USBD_HandleTypeDef *pdev,

uint8_t cfgidx)

{

uint8_t ret = 0;

/* Open EP IN */

USBD_LL_CloseEP(pdev,CDC_IN_EP);

/* Open EP OUT */

USBD_LL_CloseEP(pdev,CDC_OUT_EP);

/* Open Command IN EP */

USBD_LL_CloseEP(pdev,CDC_CMD_EP);

/* DeInit physical Interface components */

if(pdev->pClassData != NULL)

{

((USBD_CDC_ItfTypeDef *)pdev->pUserData)->DeInit();

USBD_free(pdev->pClassData);

pdev->pClassData = NULL;

}

HAL_Delay(100); //CORRECTION FOR USB CABLE UNPLUG & PLUG

return ret;

}

I do not know how good a solution is, but the problem is getting out of hand. Where can this delay be permanently added?

Thank you

    This topic has been closed for replies.

    3 replies

    ST Technical Moderator
    December 7, 2016
    Posted on December 07, 2016 at 14:55

    Dear

    Altinordu.Zekeriya

    ‌,

    Which CubeMx version are you using ?

    I will report your issue to our CubeMx team for checking this issue.

    Sorry for the inconvenience it may bring andthank you for your understanding.

    Best Regards

    -Imen-

    In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
    zekeriya
    zekeriyaAuthor
    Associate III
    December 7, 2016
    Posted on December 07, 2016 at 15:16

     ,

     ,

    Dear Imen,

    CubeMX version is 4.18.0 and

    firmware package Name and version is STM32Cube FW_F1 V1.4.0

    Thank you

    Zekeriya Altinordu

    7.12.2016 16:56 tarihinde DAHMEN.IMEN yazdı:

    >,

    STMicroelectronics Community

    <,https://community.st.com/?et=watches.email.thread>,

    >,

    Re: CubeMx, STM32F103VC, USB-VCP

    reply from IMEN D

    <,

    in /STM32 MCUs Forum/ - View the full discussion

    <,https://community.st.com/0D70X000006SKZGSA4

    >,

    Sirma Siang
    ST Employee
    February 2, 2017
    Posted on February 02, 2017 at 10:59

    Hello

    Altinordu.Zekeriya

    ,

    Your suggestion has been forwarded to the CubeMX team.

    I thank you for your enhancement suggestion.

    Kind regards

    Sirma