Skip to main content
Graduate II
October 14, 2024
Question

USB only working in debug mode

  • October 14, 2024
  • 3 replies
  • 799 views

Hi

  I am working on an STM32L433 using STM32IDE. When running in debug mode, the USB CDC is recognized when plugging in the cable (into Windows 10 and 11) . But when I compile as release mode the USB isn't recognized . I am using the HAL for USB .

 

Anyone please help on this?

 

Best Regards

Scott

    This topic has been closed for replies.

    3 replies

    Technical Moderator
    October 14, 2024

    Hi @SSmit.13 

     

    Try to lower optimization level to make sure you will get same behavior in debug mode. Then, check USB descriptors are properly configured. Connect directly USART RX to TX to test CDC in loopback.

    SSmit.13Author
    Graduate II
    October 16, 2024

    Sorry, the USB is working in release mode, I have just realized that its reading an input pin that always reads 0v . I use a jumper to detect whether to use the USB or not, and it always reads 0v in release .

     

    I have made a new thread based on this issue

     

    Many thanks

    Scott

     

     

    Technical Moderator
    October 17, 2024

    Hi @SSmit.13 

    To conclude, by ensuring proper synchronization with the __DSB() instruction, you can avoid timing issues and ensure reliable operation in both debug and release modes.