STM32 Create project in STM32CubeIDE

Installation

Install JRE or JDK first.

Download: https://www.st.com/en/development-tools/stm32cubeide.html

Create project

  • File -> New -> STM32 Project
  • Part Number Search
  • Select chip
  • Click Next
  • Set project
  • Click Finish

Chip configuration

  • Project Explorer -> <project>.ioc
  • Pinout & Configuration
  • Clock Configuration
  • Project Manager
    • Generate peripheral initialization as a pair of '.c/.h' files per peripheral
    • Keep User Code when re-generating
    • Delete previously generated files when not re-generated
  • File -> Save

Pinout & Configuration Example

HW: STM32F103C8T6(blue-pill)

  • System Core
    • RCC -> HSE -> Crystal/Ceramic Resonator
    • RCC -> LSE -> Crystal/Ceramic Resonator
    • SYS -> Debug -> Serial Wire
  • Connectivity
    • USART1 -> Mode -> Asynchronous
      • Parameter Settings -> Basic Parameters -> Baud Rate
      • NVIC Settings -> USART1 global Interrupt -> Enabled
    • USB -> Device (FS)
  • Pinout view
    • PC13 -> GPIO_Output

Clock Configuration Example

HW: STM32F103C8T6(blue-pill)

Set HCLK (MHz) to 72. Other clocks are set automatically.

Code

main.c
...
/* USER CODE BEGIN XXX */
/* USER CODE END XXX */
...
caution

When you code, write code only between USER CODE BEGIN XXX and USER CODE END XXX. If you write code elsewhere, the code generator can change it when changing the chip settings.

Last updated on