cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F103 Virtual Com Port problem

tbnkr
Associate II
Posted on July 30, 2015 at 17:55

Hello

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. */
SystemClock_Config();
HAL_Init();
MX_USB_DEVICE_Init();
uint8_t data[] = ''Hello'';
HAL_Delay(1000);
// Infinite loop
while (1)
{
HAL_Delay(1000);
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);
USBD_Start(&hUsbDeviceFS);
}

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

/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/stackexchange

but I can't make it work. Thanks!
0 REPLIES 0