0% found this document useful (0 votes)
172 views7 pages

En - STM32-Education Step3

This tutorial teaches how to program and use RS232 serial links on the NUCLEO-L476RG board and the L475 IoT Node Discovery Board (B-L475E-IOT01A). It shows how to create UART projects for each board in STM32CubeMX and TrueSTUDIO, and transmit test data over the UART interface. The goals are to get familiar with the boards, learn how to configure and use UART communication on each, and now be able to program and interface with the UART on both boards.

Uploaded by

Vikas Yadav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
172 views7 pages

En - STM32-Education Step3

This tutorial teaches how to program and use RS232 serial links on the NUCLEO-L476RG board and the L475 IoT Node Discovery Board (B-L475E-IOT01A). It shows how to create UART projects for each board in STM32CubeMX and TrueSTUDIO, and transmit test data over the UART interface. The goals are to get familiar with the boards, learn how to configure and use UART communication on each, and now be able to program and interface with the UART on both boards.

Uploaded by

Vikas Yadav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

34 min

UART and new board introduction


Target description
Following this tutorial, you will:
 get familiar with the L475 IoT Node Discovery Board,
 learn how to program and use a RS232 serial link on
 previously used NUCLEO-L476RG
 L475 IoT Node Discovery Board (B-L475E-IOT01A ).

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

 2: Introduction of L475 IoT Node Discovery Board

 3: Introduction to the UART I/F on L475 IoT Node Discovery Board

Step 3:UART and new board introduction V 1.0


12 min

CREATE NUCLEO-L476RG UART PROJECT USING CUBEMX


 Create a new project using STM32CubeMX.
 Select NUCLEO-L476RG board using board selector.
 Answer Yes to Initialize all peripherals with their default Mode ? popup.
 In Pinout tab that USART2 mode in configured to Asynchronous, PA2 is connected to USART2_TX and
PA3 is connected to USART2_RX.

 Click on USART2 button in Configuration tab and set Word Length to 8


Bits .
 Make sure that the settings are as in the screenshot below:

 Disable all other USARTs.


 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 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

CREATE B-L475E-IOT01A UART PROJECT USING CUBEMX


 Create a new project using STM32CubeMX.
 Select B-L475E-IOT01A board using board selector.
 Answer Yes to the following popup Initialize all peripherals with their default Mode ? .
 Verify in Pinout tab that USART1 mode in configured to Asynchronous.
 Click on USART1 button in Configuration tab and set Word Length to 8 Bits .

 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

You might also like