AnsweredAssumed Answered

STM32F1 USB in CDC mode

Question asked by Lukasz Przenioslo on Aug 19, 2016
Hello there,
I am struggling with this issue for over a (whole) day now... I have a custom STM32F103VBT6 board. I am trying to power up USB in CDC mode. I am using CubeMX to generate the code. At first, my USB was not visible at all by the PC. After resolving this issue my PC sees the board as unknown device now and I am not able to update the driver with inf file.
I am wondering, either this 1k5 resistor pulling up the USB line should be kept there all the time, or should I disconnect it after a certain time or event? I dont think the USB library handles this at any point at all (if it had to be disconnected later).

Interesting thing is that I also cant see the USB connection (bootloader) when entering the system memory. And I am sure I am entering that region, because my code doesnt start. Also I am not in RAM, because of the fuses (BOOT0 = 1, BOO1 = 0).

In the code, I see that program counter is once entering the USB related interrupt routine here:

/**
* @brief This function handles USB low priority or CAN RX0 interrupts.
*/
void USB_LP_CAN1_RX0_IRQHandler(void)
{
  /* USER CODE BEGIN USB_LP_CAN1_RX0_IRQn 0 */
 
  /* USER CODE END USB_LP_CAN1_RX0_IRQn 0 */
  HAL_CAN_IRQHandler(&hcan);
  HAL_PCD_IRQHandler(&hpcd_USB_FS);
  /* USER CODE BEGIN USB_LP_CAN1_RX0_IRQn 1 */
 
  /* USER CODE END USB_LP_CAN1_RX0_IRQn 1 */
}

So I gues the device is somehow aknoqledging that it is connected. When the USB is not connected, this vector is hitted by program counter constantly but no Callback is further called, it finishes here:
if (__HAL_PCD_GET_FLAG (hpcd, USB_ISTR_ESOF))
{
  /* clear ESOF flag in ISTR */
  __HAL_PCD_CLEAR_FLAG(hpcd, USB_ISTR_ESOF);
}

Even after I connect the USB back the behaviour stays the same.

The question is, why doesnt the USB work correctly? I have checked hardware connections, they are solid.

Here is the schematic

I would really, really appreciate help here... Im going insane.

Outcomes