STM32 Tutorial 03 - UART Communication Using HAL (And FreeRTOS)
STM32 Tutorial 03 - UART Communication Using HAL (And FreeRTOS)
STM32 Tutorial 03 - UART Communication Using HAL (And FreeRTOS)
You can use the STM32CubeMX tool to create the necessary config. files to enable the UART-Drivers.
The HAL library provides the necessary functions to communicate to with the UART protocol. This
feature comes in handy for debugging (printing out variables).
STM32CubeMX
Generating the config. files from STM32CubeMX.
You can also adjust the baud rate with the BaudRate parameter.
In addition to the previous function, this one terminates the string with a newline (0x0A) and a
carriage return (0x0D) command.
Create a char array, where you want to save the string to.
HAL_UART_Receive() takes this array as the second parameter.
The third parameter specifies the length of the input string, so you have to type word of exactly this
size later in the terminal.
First thing, you should check to which port your STLink debugger is connected to.
Look this one up in the Device Manager.
In PuTTY, switch the mode to Serial, enter your COM-Port address, and make sure, you have selected
the same baud rate as configured on your STM32 chip.
Then open the connection and you should see the Output in the console.
This tutorial is very basic and might not show the best way to use the STM32 environment.
It still might help you get into the whole HAL philosophy of STM if you are coming from another
platform. This document is free of copyright under the Creative Commons Zero attribution.
Simon Burkhardt
electronical engineering
simonmartin.ch
History:
V1.0 tested the code, created this document
V1.1 added information on receiving strings
V1.1.1 added contact info and cc0 notice