---
# System prepended metadata

title: STM32 - Setting Things Up
tags: [NTURT, electrical_system, firmware_hardware]

---

STM32 - Setting Things Up
===

###### tags: `firmware_hardware` `electrical_system` `NTURT`

#### Author: @andre-liang 

### Preface

This is a series of tutorial that will help you to learn about the microcontroller SMT32.

We will start from the basics (GPIO, Interrupt, ADC, Timer ... ) to advance (CAN, SPI, I2C, RTOS ... ) with hands-on experiments.

Since English is not my native language, so there might be some typo or grammatical errors, you are encouraged to fix it for me!

Also it will be easier for you to follow along if you have some basic C/C++ skills, if not, I recommand the following tutorial: https://www.w3schools.com/cpp/

### Install Software

Firstly, we need to install a IDE (Integrated Development Environment) for STM32, which consists of text editor, compiler, debuggers and other tools we need when working with STM32 project.

We will use the STM32CubeIDE: https://www.st.com/en/development-tools/stm32cubeide.html through this tutorial, choose the installer for your operating system and install the IDE with default settings.

If everything is done properly, you should see this this screen when you launch the IDE.

![](https://i.imgur.com/6Wgsnbk.png)

Then, you should install the STM32CubeProgrammer: https://www.st.com/en/development-tools/stm32cubeprog.html and STM32CubeMX: https://www.st.com/en/development-tools/stm32cubemx.html

:::warning
**Instuctions you need to follow if you install on macOS M1 chip devices**
- [STM32CubeProgrammer](/r1M8JeSrj)
- [STM32CubeMX](/By569eHSo)
:::

### Blue Pill and ST-LINK

We use the Blue Pill development board to interacte with the STM32 microcontroller. Additionally we use ST-LINK V2 to program our code into STM32's memory.

#### Pinout Layout

![reference link: https://arduino.stackexchange.com/questions/76943/pinout-for-stm32duino-with-bluepill](https://i.imgur.com/zBsLsFS.png)

![reference link: https://stm32-base.org/guides/connecting-your-debugger.html](https://i.imgur.com/ZOoVMAw.png)

Please connect the power, ground, SWCLK and SWDIO (sometimes labled as SWIO) pins on Blue Pill and ST-LINK. Then plug ST-LINK's USB connector into your PC.

If everything is done properly, you should see the red LED on the Blue Pill lights up.

![](https://i.imgur.com/XiMYv32.jpg)

### Testing

Since the Blue Pill and ST-LINK we buy online are usually clones of the original product. It is important to check if both devices are working properly.

Open STM32CubeProgrammer and try to connect to STM32 through ST-LINK. If it fails, swap to different Blue Pill/ST-link until it shows this screen.

![](https://i.imgur.com/IghnY8p.png)

Since we encounter some uncertainty when buying new components, it is recommanded that you buy it from trustworthy supplier like Mouser: https://www.mouser.tw/ .








 











