En - STM32-Education Step3
En - STM32-Education Step3
Prerequisites
Previous tutorials:
Step 1: Tools installation and first test
Step 2: Blinking LED with STM32CubeMX and HAL
Hardware
NUCLEO-L476RG board (64-pin), available on www.st.com/en/evaluation-tools/nucleo-l476rg.html
STM32L4 Discovery kit IoT node (B-L475E-IOT01A ), available on
www.st.com/en/evaluation-tools/b-l475e-iot01a.html
USB cables ‘Type-A to Mini-B’ and ‘Type-A to Micro-B’
Literature
STM32L4 Online Training: STM32L4_Peripheral_USART
UM1F727 Getting started with STM32 Nucleo board software development tools
Stages
1: Introduction to the UART I/F on NUCLEO-L476RG
Go to Project menu and click on Settings. Select TrueSTUDIO as Toolchain / IDE, give a name to your
project then click OK .
Click on Project then Generate Code and accept to open your project in TrueSTUDIO.
2
EDIT AND COMPILE NUCLEO-L476RG UART PROJECT USING TRUESTUDIO
Open main.c in Project Explorer / myproject / Src / main.com.
Insert the following lines:
uint8_t Test[] = "Hello World !!!\r\n"; //Data to send
HAL_UART_Transmit(&huart2,Test,sizeof(Test),10);// Sending in normal mode
HAL_Delay(1000);
between /* USER CODE BEGIN 3 */ and /* USER CODE END 3 */
Click on Build button to compile the project.
Click in Debug button to run the software.
Click on Console button to open a console, select Data bits: 8 and click OK . Port name may differ on
your PC.
TrueSTUDIO will open Debug perspective. Click on Resume button to execute your code.
Terminal Window will display Hello World !!! string confirming you were able to program and use RS232.
3
10 min
4
12 min
Verify that Baud Rate is 115200 Bits/s, Parity is None and Stop Bits is 1 .
Disable all other USART.
Click on Apply then OK .
Go to Project menu and click on Settings. Select TrueSTUDIO as Toolchain / IDE , give a name to your
project then click OK.
Click on Project then Generate Code and accept to open project in TrueSTUDIO.
5
EDIT AND COMPILE B-L475E-IOT01A UART PROJECT USING TRUESTUDIO
Open main.c in Project Explorer / myproject / Src / main.com .
Insert the following lines:
uint8_t Test[] = "Hello World !!!\r\n"; //Data to send
HAL_UART_Transmit(&huart1,Test,sizeof(Test),10);//Sending in normal mode
HAL_Delay(1000);
between /* USER CODE BEGIN 3 */ and /* USER CODE END 3 */
Click on Build button to compile the project.
Click in Debug button to run the software.
Click on Console button to open a console, select Data bits: 8 and click OK. Port name may differ
on your PC.
TrueSTUDIO will open Debug perspective. Click on Resume button to execute our code.
Terminal Windows will display Hello World !!! string confirming we were able program and use RS232.
6
Now you are able to:
use the UART I/F on NUCLEO-L476RG
use L475 IoT Node Discovery Board
use the UART I/F on L475 IoT Node Discovery Board