2023-11-30 05:01 AM
Hello ,
As per reference document added USB driver in firmware , but gives error at function
USBD_SetClassConfig(pdev, cfgidx);
added screenshot of error
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
2023-12-03 06:20 AM
Go into USBD_SetClassConfig and figure out why it's failing. Set a breakpoint, step through.
2023-12-04 02:53 AM
Hello ,
USBD_EMEM error received in USBD_SetClassConfig
2023-12-04 05:57 AM
Keep following it. Go into the Init function and find where that failed...
2023-12-05 01:08 AM
it will fail in CDC_INIT function
pdev->pClassDataCmsit[pdev->classId] always return a NULL value
2023-12-05 03:57 AM
Hello ,
Can you please explain when USBD_EMEM error received or any details about USBD_EMEM .
2023-12-05 06:22 AM
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.