cancel
Showing results for 
Search instead for 
Did you mean: 

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

jlecl.1
Associate III

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 ?

1 ACCEPTED SOLUTION

Accepted Solutions
jlecl.1
Associate III

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));

View solution in original post

7 REPLIES 7

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
Up vote any posts that you find helpful, it shows what's working..
MM..1
Chief III

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

and for your code chapter 7

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
Associate III

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
Associate III

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));

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
Up vote any posts that you find helpful, it shows what's working..
MM..1
Chief III

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.