AnsweredAssumed Answered

STM32F103 Virtual Com Port problem

Question asked by Teddy Bonkers on Jul 30, 2015

I have been trying to implement the VCP on a chip I am working on. I do not have any experience with USB and I just want to get this working so I can send some data to the device (will focus on USB later). I am using Eclipse + GCC and Cube for the initialising code. My PC recognizes the chip as COM port so far. Here's my code:
nt main(int argc, char* argv[])
    /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
    uint8_t data[] = "Hello";
    // Infinite loop
    while (1)
        CDC_Transmit_FS(data, 5);
void MX_USB_DEVICE_Init(void)
  /* Init Device Library,Add Supported Class and Start the library*/
  USBD_Init(&hUsbDeviceFS, &FS_Desc, DEVICE_FS);
  USBD_RegisterClass(&hUsbDeviceFS, &USBD_CDC);
  USBD_CDC_RegisterInterface(&hUsbDeviceFS, &USBD_Interface_fops_FS);

However, when I call CDC_Transmit_FS(), I get a hard fault in the function USBD_CDC_SetTxBuffer(). The function CDC_Init_FS() is never called and the USBD_CDC_SetTxBuffer() function uses a variable that is never initialized. I saw a thread with a problem identical to mine at but I can't make it work.