cancel
Showing results for 
Search instead for 
Did you mean: 

USB reconnection issue after microcontroller reset

Muhammad Moiz khan
Associate II
Posted on November 09, 2016 at 13:12

Hi,

I am working on USB in VCP mode, and sending some of my data to PC-terminal, while working I'd notice that on first USB established connection microcontroller sends my data to the PC correctly, however when microcontroller reset USB stops sending its data to terminal, I don't understand what the reason behind that since in the past I'd been using FTDI Serial-to-USB converter in the same scenario and it worked fine.

Any help in this regard would be highly appreciated.

Regards,

Muhammad Moiz khan 
10 REPLIES 10
Muhammad Moiz khan
Associate II
Posted on December 01, 2016 at 12:25

Hello guys,

 

Thanks for the support, I have tried it your way, I disconnected my USB using DCD_DevDisconnect function before resetting my microcontroller, but it follows the same results, the terminal don't receive my strings after reset on the other side after resetting, microcontroller connects once again, however terminal don't adapt to the changes done in the COM port, below is my code. 

int main(void)

{

  /*System clock Intialization*/

  SystemInit();

  if (RCC_GetFlagStatus(RCC_FLAG_PINRST==SET))

  {

  RCC_ClearFlag();

  }

  /*SyStick configuration to set up delay in millisecond*/

  SysTick_Config(SystemCoreClock/1000);

  /*GPIO configuration*/

  GPIO_config();

  /*USB Intialization*/

  USBD_Init(&USB_Device_dev, &USR_desc, &USBD_CDC_cb, &USR_cb);

  while (1)

  {

  if (USB_Device_dev.dev.device_status==USB_CONFIGURED)

  {

  for (a=0; a<1000; a++)

  {

         /*Must provide delay of atleast 5 ms when sending the string*/

  VCP_Send_String(''\r\nUSB'', 6);

  /*Adding Delay*/

  Delay(10);

  GPIO_SetBits(GPIOB,GPIO_Pin_2);

  }

  /*Disconnecting the USB before system reset*/

  DCD_DevDisconnect(&USB_Device_dev);

  Delay (20);

  /*Reset the microcontroller*/

 NVIC_SystemReset();

  }

  else

  {

    GPIO_SetBits(GPIOB,GPIO_Pin_2);

    Delay(100);

    GPIO_ResetBits(GPIOB,GPIO_Pin_2);

    Delay(100);

  }

  }

}

Regards,

Muhammad Moiz khan