Skip to main content
jlecl.1
Associate III
Jan 14, 2023 3:25 PM UTC
Solved

Hello, I'm begginner on stm32 and i try to program, without succes, a VCP on NucleoBoard L152re.

My code is simply :

HAL_Delay(100);
	 HAL_GPIO_TogglePin(GPIOA,GPIO_PIN_5);
 
	 uint8_t buffer[] = "Hello, World!\r\n";
	 CDC_Transmit_FS(buffer, sizeof(buffer));

But nothing...

> The led is blinking.

> The VCp is define via *.IOC with no error.

> Compilation without error.

I see a VCP but i think is the st-link debugger VCP.

It's right ?

Do you have advice for me ?

This topic has been closed for replies.
jlecl.1
jlecl.1Best answer
Associate III
Jan 14, 2023 5:28 PM UTC

ok, i have unterdand.

NO vcp by configure VCP port BUT juste by UART2 !

char buffer[]="Hello\r";
	 	 HAL_Delay(100);
	 	 HAL_GPIO_TogglePin(GPIOA,GPIO_PIN_5);
	 	 HAL_UART_Transmit(&huart2, (unsigned char *)&buffer, 6, sizeof(buffer));

7 replies

Tesla DeLorean
Guru
Jan 14, 2023 3:56 PM UTC

You'd need to have soldered on a USB connection to get one directly from the STM32L152

The primary USB connection is for the ST-LINK/V2 and connects to the STM32F103 on the board.

To use the ST-LINK VCP you'll need to output to the connected UART

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
MM..1
Super User
Jan 14, 2023 4:03 PM UTC

Maybe good for beginer is STM32 microcontroller debug toolbox - Application note

and for your code chapter 7

jlecl.1
jlecl.1Author
Associate III
Jan 14, 2023 4:57 PM UTC

hummm, sure BUT !

on page we can read :

"Embedded versions usually supports the following additional features:

• Virtual COM port interface on USB. (VCP)

• Mass storage interface on USB".

It's not very clear

jlecl.1
jlecl.1Author
Associate III
Jan 14, 2023 4:58 PM UTC

idem page 68

STM32 Virtual COM port driver STM32 Virtual COM Port Driver (VCP) is a feature supported by ST-LINK/V2-B embedded in most of recent hardware kits (refer to Section 2.1: Hardware development tools on page 9). It is a RS232 emulation through ST-LINK USB connection. On the PC side, this requires driver software package (STSW-STM32102) included in STLINK driver (STSW-0009). Once the target is connected, it is seen as a serial port on the PC. An example is presented in Figure 47.

jlecl.1
jlecl.1AuthorBest answer
Associate III
Jan 14, 2023 5:28 PM UTC

ok, i have unterdand.

NO vcp by configure VCP port BUT juste by UART2 !

char buffer[]="Hello\r";
	 	 HAL_Delay(100);
	 	 HAL_GPIO_TogglePin(GPIOA,GPIO_PIN_5);
	 	 HAL_UART_Transmit(&huart2, (unsigned char *)&buffer, 6, sizeof(buffer));

Tesla DeLorean
Guru
Jan 14, 2023 5:40 PM UTC

The last parameter is a timeout, not a length, use strlen() to count characters in strings.​

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
MM..1
Super User
Jan 14, 2023 7:21 PM UTC

Your best answer isnt very best. Primary VCP configured port CDC is for USB interface on target MCU, not for onboard STLink debuger.

Secondary &buffer isnt normal addr , right is &buffer[0] or only buffer etc.