Skip to main content
Visitor II
April 29, 2025
Question

HAL_PCD PCD_GET_EP_RX_CNT only return 0

  • April 29, 2025
  • 1 reply
  • 293 views

Hello,

 

I am working on a stm32u083rc. I'm trying to establish a USB Serial connection using the HAL_PCD library. I'm at the enumeration stage and trying to read the data sent by the PC (windows).

The USB device is initialized with CubeMX (STM32Cube FW_U0 V1.2.0) in Device only, Full Speed, interrupts enabled.

In my setup, I call the HAL_PCD_Start() function. Windows will detect a connection and attempt to enumerate it. At this point, the HAL_PCD_ResetCallback() function is called and I open EP0 in and out :

    HAL_PCD_EP_Open(hpcd, 0x00, 64, EP_TYPE_CTRL);
    HAL_PCD_EP_Open(hpcd, 0x80, 64, EP_TYPE_CTRL);
Next, the HAL_PCD_SetupStageCallback() function is called and I'm supposed to respond to requests from the PC (USB host). Unfortunately, before calling this function, in the PCD_EP_ISR_Handler() function (line 1605 in file stm32u0xx_hal_pcd.c) :
/* Get SETUP Packet *
ep->xfer_count = PCD_GET_EP_RX_CNT(hpcd->Instance, ep->num);
Always returns 0, as if no request had been received.
 
How do I do it?
 
    This topic has been closed for replies.

    1 reply

    Technical Moderator
    May 2, 2025

    Hi @frangipane 

    Your device is still not addressed at this stage! 

    Do you have an issue using cube firmware example? Otherwise would you attach minimum project to reproduce the issue if present?