USB CDC on F103C8T6 detected by PC but not working in any way - pClassData is always a null pointer
Hello.
The device is correctly detected by the PC as a COM port and I can open the connection with some terminal. Although I can't send anything through it in any way.
I've tried using CDC_Transmit_FS (from usbd_cdc_if.c) after waiting some time for the USB to initalize, but it returns USBD_BUSY every time. The problem is at these lines:
USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef*)hUsbDeviceFS.pClassData;
if (hcdc->TxState != 0){
return USBD_BUSY;
}It seems that pClassData is always a null pointer, so TxState contains some garbage.
According to my investigation, in function USBD_CDC_Init() (usbd_cdc.c) there is some malloc, which should assign an address to pClassData:
pdev->pClassData = USBD_malloc(sizeof(USBD_CDC_HandleTypeDef));But the problem is that USBD_CDC_Init() is NEVER called (checked with a breakpoint). Chaning this line to statically assign some dummy address to pClassData also has no effect. In the result I can't send anything and there is no reaction when I send something from the PC.
I'm using STM32CubeMX for this. The problem is present also in plain, fresh generated code.
Does anyone have any idea?
Thanks in advance
