Tutorial: arduino-stm32 Installation

Overview

In this tutorial, you will use arduino IDE compiler to handle several peripherals of MCU (ARM-Cortex M4). Using the given platform, you will perform some tasks about GPIO, timer and interrupt.

The objectives of this lab are

  • Connect STM32F (MCU board) to arduino IDE.

  • Understand digital in/out peripheral in MCU.

  • Understand timer and interrupt function of MCU.

  • Handle GPIO, timer and interrupt using arduino library.

Hardware

​ Figure 1. Pin configuration for NUCLEO-F411RE board (same pin configuration with NUCLE-F401Re)

Tutorial

Installing arduino IDE

Open https://www.arduino.cc/en/software

Click "Windows Win 7 and newer" in Download options. Then, you should click "JUST DOWNLOAD" for free.

image

경로에 한글이름, 띄어쓰기 금지(오직 영어만 있어야 함)

image

Installing STM32 MCU based boards in arduino IDE

Add STM32 MCU board manager URL

On menu bar, select File > Preferences

Then, add board manager URL

https://github.com/stm32duino/BoardManagerFiles/raw/main/package_stmicroelectronics_index.json

image

Install STM32 MCU based boards

On menu bar, select Tools > Board: " " > Boards Manager...

Install STM32 MCU based boards.

image

Hardware Setting

Option 1: Download en.stsw-link009_v2.0.2.zip from github

Option 2: Download driver (STSW-LINK009) from ST website

ST-LINK, ST-LINK/V2, ST-LINK/V2-1, STLINK-V3 USB driver signed for Windows10. This USB driver (STSW-LINK009) is for ST-LINK/V2, ST-LINK/V2-1 and STLINK-V3 boards(STM8/STM32 discovery boards, STM8/STM32 evaluation boards and STM32 Nucleo boards).

It declares to the system the USB interfaces possibly provided by the ST-LINK: ST Debug, Virtual COM port and ST Bridge interfaces. The driver must be installed prior to connecting the device, in order to have a successful enumeration.

After you download "en.stsw-link009_v2.0.2.zip", unzip the file.

Connect MCU board to PC with USB cable.

Update the usb driver: 윈도우 장치 관리자 > 범용직렬버스장치> ST-Link Debug >드라이버 업데이트>

  • Select the folder where en-stsw-link009 is unzipped

MCU board (STM32F411) must be connected to your PC to install the USB driver

What is ST Link utiliy? https://m.blog.naver.com/ansdbtls4067/221510252896

Connect STM32F401RE through USB port

Check the port number and settings in "device manager".

  • baudrate: 9600

  • data bits: 8

  • parity: None

  • Stop bit: 1

  • Flow control: None

image

Connect STM32F401RE to arduino IDE

Arduino Setting for STM32F411RE

  • Board: Nucleo-64

  • Board part number: Nucleo F411RE

  • Port: USB port number connected with STM32 Board

There is a simple example, that LED blinks every 1 sec.

On menu bar of Arduino IDE, select File > Examples > 01.Basics > Blink

Then, new window will be opened. If you click upload button, the example code will be loaded on the MCU.

If the program is loaded successfully then LED(LD1) will be green light.

image

Troubleshooting Upload Issues

Step 1: Download & Install STM32CubeProgrammer 📥

Go to the Download Page: Visit the official STM32CubeProg download page.

Get the Software: Click "Get Software" to download the latest version. You may need to create a free ST account.

Install It: Run the downloaded installer. The default settings are fine, so just click through the installation. The tool will typically be installed at: C:\Program Files\STMicroelectronics\STM32Cube\STM32CubeProgrammer

Step 2: Set Up the Environment Path 🗺️

This step tells your computer where to find the program.

Open Environment Variables: In the Windows search bar, type "Edit the system environment variables" and open it.

Click "Environment Variables...": A new window will open.

Edit the Path: In the "System variables" section, find and double-click on the Path variable.

Add the New Path: Click New and add the path to the bin folder from your installation. It should look like this: C:\Program Files\STMicroelectronics\STM32Cube\STM32CubeProgrammer\bin

Confirm: Click OK on all windows to close and save the changes.

Step 3: Configure Arduino IDE & Upload 🔄

Restart Arduino IDE: This is very important! Completely close and reopen the Arduino IDE for the new settings to take effect.

Set the Upload Method: In the Arduino IDE, go to the Tools menu.

Board: Make sure your Nucleo-F411RE is selected.

Upload Method: Click on this and select STM32CubeProgrammer (SWD).

Upload Your Sketch: Try uploading your code again. It should now work perfectly!

Last updated

Was this helpful?