Skip to main content
Associate II
Nov 30, 2023 1:01 PM UTC
Question

STM32H563ZI : USB CDC issue

Hello , 

As per reference document added USB driver in firmware , but gives error at function 

USBD_SetClassConfig(pdev, cfgidx);

added screenshot of error

stm32_error.png

 

If ignore this error , USB Serial device port detected but failed to set transmission buffer

static int8_t CDC_Itf_Init(void)

{

// Set Application Buffers

USBD_CDC_SetTxBuffer(&USBD_Device,UserTXBuf,0); //USBD FAIL error received

USBD_CDC_SetRxBuffer(&USBD_Device,UserRXBuf);

// Initialize buffer pointers

UserRXBufCur = 0;

UserRXBufLen = 0;

return (USBD_OK);

}

please suggest answer

    This topic has been closed for replies.

    6 replies

    TDK
    Dec 3, 2023 2:20 PM UTC

    Go into USBD_SetClassConfig and figure out why it's failing. Set a breakpoint, step through.

     

    "If you feel a post has answered your question, please click ""Accept as Solution""."
    poojaAuthor
    Associate II
    Dec 4, 2023 10:53 AM UTC

    Hello ,

    USBD_EMEM error received in USBD_SetClassConfig

    STM32_USB_Set_config_error.png

    TDK
    Dec 4, 2023 1:57 PM UTC

    Keep following it. Go into the Init function and find where that failed...

    "If you feel a post has answered your question, please click ""Accept as Solution""."
    poojaAuthor
    Associate II
    Dec 5, 2023 9:08 AM UTC

    it will fail in CDC_INIT function 

    pdev->pClassDataCmsit[pdev->classId] always return a NULL value 

    classId_STM32_NULL.png

    TDK
    Dec 5, 2023 2:22 PM UTC

    Step through USBD_malloc and understand why it's failing. On newer HAL USB versions, this is a static allocation which can never fail. On older ones it called malloc, which should work, but may not if you have insufficient heap space.

    USBD_EMEM indicates a memory error.

    "If you feel a post has answered your question, please click ""Accept as Solution""."