- 

Created:2018-11-14  Last modified:2018-11-14


  1. Introduction

    Nucleo development board's st-link provides a virtual serial port. It connects the UART2.

    This example uses the polling mode (without interrupt and DMA) of the UART to print infomation to a PC.

  2. Example

    1. Use STM32CubeMX to initalize project.
      Select USART2 as asynchronous mode, setup clock, configurate the uart. This example use 115200bit/s, 8bit length without parity, 1 stop bit.
    2. Keil: Write code and deploy.
                          uint8_t buffer[20] = "Hello, World!\n\r";
                          while(1)
                          {
                              counter = counter % 10;
      		                buffer[0] = '0' + (counter++);
      		                HAL_UART_Transmit(&huart2, buffer, 20, 1); 
                              HAL_Delay(200);
                          }
                      
    3. Open PC COM monitor (This example use RealTerm)
      Select the right port number (check at Windows device manager) and configurate the COM
  3. References