Skip to main content

Getting Started with STM32

What is STM32 / When to Use It

STM32 is a family of 32-bit ARM Cortex-M microcontrollers by STMicroelectronics. Use STM32 for real-time control, precise timing, CAN bus, industrial communication, or DSP.

Which STM32?

SeriesCoreSpeedFlashBest For
STM32F103 Blue PillCortex-M372 MHz64 KBBudget learning, basic control
STM32F407 BlackCortex-M4F168 MHz512 KBDSP, motor control, audio
STM32G0Cortex-M0+64 MHz32 KBLow power, cost-sensitive
STM32H743Cortex-M7480 MHz1 MBHigh-speed DSP, AI inference
STM32WLCortex-M4 + LoRa48 MHz256 KBLoRaWAN end-devices

Prerequisites

  • STM32 dev board (Nucleo, Discovery, or Blue/Black Pill)
  • ST-Link v2 programmer (Nucleo/Discovery have built-in)
  • USB cable

Install Toolchain

  1. Download from st.com (free, needs ST account)
  2. Install and launch
  3. Create new project: File → New → STM32 Project
  4. Select your MCU (e.g., STM32F407VGT6)
  5. Configure pins in the .ioc file (graphical pinout editor)
  6. Generate code — CubeMX creates HAL init code automatically

PlatformIO (VSCode)

platformio init --board black_f407ve

Framework: stm32cube (HAL) or libopencm3 (lightweight).

ARM GCC + Make (Advanced)

sudo apt install gcc-arm-none-eabi openocd
#include "main.h"
void SystemClock_Config(void);
static void MX_GPIO_Init(void);

int main(void) {
HAL_Init();
SystemClock_Config();
MX_GPIO_Init();
while (1) {
HAL_GPIO_TogglePin(GPIOD, GPIO_PIN_12);
HAL_Delay(500);
}
}

Common Issues

ProblemFix
ST-Link not detectedInstall ST-Link driver from st.com
No serial outputEnable UART in CubeMX pinout config
Wrong chip detectedCheck SWD wiring — SWCLK/SWDIO not swapped
Code too largeBlue Pill only 64 KB; upgrade to F4
CubeIDE slowUse PlatformIO instead
  1. Set BOOT0 pin HIGH, BOOT1 LOW
  2. Connect USB-UART to PA9 (TX) and PA10 (RX)
  3. Use stm32flash: stm32flash -w firmware.bin -v /dev/ttyUSB0
Questions about this guide?

Ask on the Community Forum — share your project, get help, or help others.

Next Steps