Skip to main content
Graduate
May 26, 2024
Solved

USB virtual COM port does not work when debugging

  • May 26, 2024
  • 2 replies
  • 2248 views

Hello,

 

I am trying to debug my vcp application (uses STM32F103CBT6), but when I start a debug session the COM port does not work. When not debugging, just uploading a new code, the cdc communication only works after a power reset. I modified my custom board: added transistors to the DP pull up resistor to be able to disconnect it from 3v3 with code, but it does work, it won't reenumerate the device.

When debugging, CDC_Control_FS() never get called.

the function looks like this: 

PSzab1_0-1716736470675.png

I tried everything i can foud on the internet, but nothing worked.

I have also read this: https://community.st.com/t5/stm32-mcus-products/usb-cdc-dont-work-in-debug/m-p/464797

The USB variables when the communication is not working:

PSzab1_1-1716737814331.png

PSzab1_2-1716737848410.png

PSzab1_3-1716737879365.png

and the registers:

PSzab1_4-1716738030697.png

 

 

 

 

    This topic has been closed for replies.
    Best answer by Muhammed Güler

    I have used USB with the following method before.
    By directly connecting the dp pull up resistor to an IO,
    When the device is reset, set the dp pull up resistor to 0.
    I set the output to 1 just before the USB setup function.
    here is part of my schematic

    MuhammedGler_0-1716740443424.png

     

    2 replies

    Graduate II
    May 26, 2024

    I have used USB with the following method before.
    By directly connecting the dp pull up resistor to an IO,
    When the device is reset, set the dp pull up resistor to 0.
    I set the output to 1 just before the USB setup function.
    here is part of my schematic

    MuhammedGler_0-1716740443424.png

     

    PSzab.1Author
    Graduate
    May 26, 2024

    Thank you! This worked. I did not think of this.

    BTW first I tried what ST uses in their schematic:

    PSzab1_0-1716744111562.png

    but this did not work at all.

    Then I built what I thought will work:

    PSzab1_1-1716744178241.png

    and this is working in normal case, but not in debug case.

     

     

    Technical Moderator
    May 27, 2024

    Hi @PSzab.1 

    Would you please tell me where you found the implementation? 

     

    FBL_1-1716802839404.png

    I'm suspecting a mismatch with the current implementation on F103 eval board.

    FBL_0-1716802816585.png

     

    Graduate II
    May 26, 2024

    Debugging and real-time operation are generally not compatible. Watch out also peripheral views, and invasive effects on related registers and FIFOs

    Perhaps find other ways to diagnose what's happening with your code. Instrumentation to understand dynamic flow and interactions can be helpful to pin-point what behaviour and sequences are problematic.