cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H563ZI : USB CDC issue

pooja
Associate II

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

6 REPLIES 6
TDK
Guru

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".
pooja
Associate II

Hello ,

USBD_EMEM error received in USBD_SetClassConfig

STM32_USB_Set_config_error.png

TDK
Guru

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".
pooja
Associate II

it will fail in CDC_INIT function 

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

classId_STM32_NULL.png

pooja
Associate II

Hello ,

Can you please explain when USBD_EMEM error received or any details about USBD_EMEM .

 

TDK
Guru

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".