cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L151 USB Virtual COM Port not working

nicklat
Associate II

Hello everyone,

During the last few days I have been trying to set the USB Peripheral from STM32L151CC microcontroller as a Virtual COM Port from STM32CubeIDE.

Unfortunately no matter what I've tried the USB is not recognized. (Tested both in Linux and Windows 10).

In the attachments you can find the settings I've used in STCubeMX for the particular device.

Edit: I use the Multitech xDot and that's why I've configured an HSE clock source.

Any help would be much appreciated.

Best regards,

Nick

3 REPLIES 3

Hello @nicklat​ 

Could you please share your .ioc file to check with.

Best regards,

Nesrine

nicklat
Associate II

Hi Nesrine.

Where is the previous answer that ST provided? There was a bug with STM Cube and a specific function generated by the IDE required modification.

The answer that was previously posted in this topic solved the problem.

Please post it again.

Best regards,

Nick

nicklat
Associate II

I post here the answer emailed to me for anyone who might have the same problem and future references.

"In fact this specific MCU (L151, but also L152) has an internal pull-up on the USB DPlus pin but by default this pull-up, required to trigger the enumeration, is not set. This is normally done in the HAL_PCDEx_SetConnectionState() function that is atomatically called on connection, in the generated code this function is declared as weak and must thus by overwritten in the usbdconf.c file, add the following: /** * @brief Software Device Connection * @param hpcd: PCD handle * @param state: connection state (0 : disconnected / 1: connected) * @retval None */ void HAL_PCDEx_SetConnectionState(PCD_HandleTypeDef *hpcd, uint8_t state) { if (state == 1) { /* DP Pull-Down is Internal */ __HAL_SYSCFG_USBPULLUP_ENABLE(); } else { /* DP Pull-Down is Internal */ __HAL_SYSCFG_USBPULLUP_DISABLE(); } } Note that in all the USB Cube Firmware examples provided for the L1 family this function is indeed re-declared in the usbdconf.c, this is missing when generating the code from CubeMX/CubeIDE while it should be there since it is MCU dependent. Sorry for the inconvenience, please find attached a project generated from CubeIDE 1.4 for NUCLEO-L152RE with the modification, this project just shows the proper enumeration of the device, not specific feature."