A step-by-step guide for setting up STM32 projects using both HAL (Hardware Abstraction Layer) and Bare-Metal (No HAL) programming approaches with the NUCLEO-F446RE development board.
- Prerequisites
- HAL Programming Workflow
- Bare-Metal Programming Workflow
- Project Workspace Location
- Terminal Setup
- Notes
Make sure the following tools are installed before getting started (version 2.1.0):
- Software:
- Terminal:
- PuTTY (Windows)/ GTKterm (Linux)
💡You can also use integrated Command Shell Console in STM32CubeIDE. See Terminal Setup to configure the console.
- Hardware: NUCLEO-F446RE development board
- Cable: USB Type-A to Mini-B
- Operating System: Windows/ Linux
HAL (Hardware Abstraction Layer) programming uses STM32CubeMX to auto-generate initialization code, which is then imported into STM32CubeIDE.
STM32CubeMX
└── From New Project
└── Start My Project from MCU
└── ACCESS TO MCU SELECTOR
└── Commercial Part Number: STM32F446RET6TR
└── Start Project
└── Initialize all peripherals with default mode? → Yes
Project Manager
├── Project Name → LAB_1B <your-project-name>
├── Project Location → C:\Users\USER\STM32CubeIDE\workspace_2.1.0\ <your-project-location>
└── Toolchain / IDE → STM32CubeIDE
└── GENERATE CODE
Prompts during generation:
Prompt Action Project Manager Settings Popup Click Yes Notification Select Don't ask me again Licence Agreement Click Agree → Finish Windows Security Alert Click Allow Success Dialog Click Close
STM32CubeIDE
└── File
└── Open Projects from File System
└── Import Source → Select project folder → Finish
Bare-metal programming gives full control over hardware without abstraction layers. Projects are created directly in STM32CubeIDE.
STM32CubeIDE
└── File
└── STM32 Project Create/Import
└── Create New STM32 Project
└── STM32CubeIDE Empty Project
└── Next
└── MCU/MPU Selector → STM32F446RETx
└── Next
└── Project Name → LAB_1A <your-project-name>
└── Finish
1. Copy 'Drivers' folder from HAL-based project that was created.
2. Paste it into current project.
3. Delete the 'STM32F4xx_HAL_Driver' from 'Drivers' folder.
4. Go to 'Drivers -> CMSIS -> Include' and 'Drivers -> CMSIS -> Device -> ST -> STM32F4xx -> Include':
select Add/remove include path... -> OK
⚠️ Without the CMSIS driver, you cannot use predefined mnemonics. You must either define them yourself or use direct register values and addresses.
By default, STM32CubeIDE projects are saved at:
C:\Users\USER\STM32CubeIDE\workspace_2.1.0\
💡 You can change this location during the IDE's initial workspace setup or via File → Switch Workspace.
We need a serial terminal to communicate with the computer via USART protocol. Follow these steps to configure the integrated serial terminal in STM32CubeIDE:
- Go to 'open console', select 3 Command Shell Console.
- Put this:
- Connection Type: Serial Port
- Connection name → USART2
<your-serial-port-name>or New Serial Port Connection - Encoding: UTF-8
- New serial port connection settings:
- Connection name: give it a name according to your preference
- Serial port: COM4
<STLink-Virtual-COM-Port> - Baud rate: 115200
- Data size: 8
- Parity: None
- Stop bits: 1
⚠️ Must match with your USART configuration of NUCLEO-F446RE device - How to find port number:
- Go to 'Device Manager'
- Find 'Ports (COM & LPT)' from the list
- Expand it, and you will see the port number
STMicroelectronics STLink Virtual COM Port (COM4)
⚠️ Your NUCLEO-F446RE device must be connected with computer via cable
- Replace
<your-project-name>and<your-project-location>with your actual project name and desired save path. - The HAL workflow is recommended for beginners as it auto-generates peripheral configuration code.
- The Bare-Metal workflow is ideal for advanced users who want full hardware control.
- Arduino Uno pin diagram:
If you found this guide helpful, please consider starring the repository to show your support. Your star would help increase the visibility and also encourage more learners to discover and benefit from it.
This project is open-source under GPL-3.0 license. Feel free to use and modify it as needed.
Image source: STMicroelectronics


