Skip to main content
Moritz Diller
Associate III
July 26, 2018
Question

USB Stall Behavior (CubeMx, CDC)

  • July 26, 2018
  • 2 replies
  • 1028 views

Hi,

I'm struggling to integrate a USB interface into a bootloader. The microcontroller always stalls the USB communication. To find the cause of this problem I have set up a simple project to compare the USB transfers and came to a point where I can't explain the behavior of the USB periphery.

1) Failed USB transfer

0690X0000060OGFQA2.png

LED_BLUE is toggled in USBD_LL_StallEP(...) of usbd_conf.c. After that, the PID OUT request from the host ist answered with a STALL handshake packet. Seems reasonable.

2) Successful USB transfer

0690X0000060OGPQA2.png

In the reference project USBD_LL_StallEP(...) is called as well, but the PID OUT request is answered with NAK, not with STALL. Next, the host retransmits PID OUT, which is ACKed by the device and everything works fine. USBD_LL_ClearStallEP(...) is never called, so why does the communication not stall?

Any tips on how to explain this behavior?

Kind regards,

Moritz

    This topic has been closed for replies.

    2 replies

    waclawek.jan
    Super User
    July 26, 2018

    Which mcu?

    JW

    Moritz Diller
    Associate III
    July 27, 2018

    MCU is STM32L433CC. Meanwhile, I found the solution: I used an old version of the HAL library in my project, whereas the reference project had the latest HAL version. I didn't figure out the exact cause for this error, but in the old HAL lib the USB interrupt didn't fire after USBD_LL_StallEP(...). Maybe the stall configuration gets revoked by the interrupt. In the following screenshots, the third signal is toggled in the interrupt handler.

    1) Failed USB-Transfer (old HAL version)

    0690X0000060OoxQAE.png

    2) Successful USB transfer (latest HAL version)0690X0000060Op2QAE.png