Skip to main content
jlecl.1
Associate III
January 14, 2023
Solved

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

  • January 14, 2023
  • 7 replies
  • 1649 views

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.
Best answer by jlecl.1

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
January 14, 2023

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
January 14, 2023

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

and for your code chapter 7

jlecl.1
jlecl.1Author
Associate III
January 14, 2023

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
January 14, 2023

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
January 14, 2023

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
January 14, 2023

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
January 14, 2023

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.