cancel
Showing results for 
Search instead for 
Did you mean: 

How to run BLE and virtual com port at a time.

DineshB
Associate III

I am trying to run BLE stack and VCP at the same time but when BLE stack run then VCP disables automatically.

Thank you in advance for reply.

5 REPLIES 5
BGeig.3
Associate II

+1

I have exactly the same problem right now. Everything is configured in CubeMX and

MX_USB_Device_Init();

is called.

If I comment out

//MX_APPE_Init();

the device is detected as CDC device on the PC.

But if STM32_WPAN is initialized (MX_APPE_Init(); called) the device is not detected as CDC device by the PC: "USB device not recognized"

Edit:

I have tried to narrow down the problem by comment out function calls:

MX_APPE_Init() -> appe_Tl_Init() -> TL_Init()

If I comment out this line in tl_mbox.c, VCP is running (but BLE not):

TL_RefTable.p_device_info_table = &TL_DeviceInfoTable;

Thanks! :full_moon_face:

Remy ISSALYS
ST Employee

Hello,

When you call VCP_Init function, a null pointer is give as second parameter, instead this null pointer, give a rx buffer in parameter like this:

VCP_Init( &VcpTxBuffer[0], &VcpRxBuffer[0] );

And declare the rx buffer like this:

static uint8_t VcpRxBuffer[MAX_DBG_TRACE_MSG_SIZE]; /* Receive buffer over USB */

Best Regards

DineshB
Associate III

Thank you Remy for reply

But in my code CubeMx didn't generate VCP_Init function it generates MX_USB_Device_Init function for usb device (CDC) for virtual com port.

hi BGeing.3

Just call this LL_HSEM_1StepLock( HSEM, 5 ); before calling MX_APPE_Init function.

Remy ISSALYS
ST Employee

Hello,

Sorry, I made a confusion, in your case you can look STM32WB-BLE-USB-CDC-VCOM example available on STM32 Hotspot GitHub. This example demonstrates how to use the BLE component alongside the USB peripheral for point-to-point communications. The application runs the BLE component as a GAP Peripheral and GATT Server, and the USB as a Device Communication Class (CDC), this is a typical application on how to use the STM32WBxx USB Device peripheral where the STM32WB MCU behaves as a USB-to-RS232 bridge following the Virtual COM Port (VCP) implementation.

In AN5289 on figure 9, there is a description that show how to use USB on CPU1 because the USB and RNG IPs share the same source clock, so you should manage semaphore.

Best Regards