This repo contains some basic examples for STM32.
LibOpenCM3 is an open source ARM Cortex-M microcontroller library.
My blog posts: 簡單入門 LibOpenCM3 STM32 嵌入式系統開發
Examples | F103RB | F446RE | F401RE | F302R8 | L432KC | G431KB |
---|---|---|---|---|---|---|
Blinking LED | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
GPIO input | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | |
EXTI button | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | |
USART with printf() | ✔️ | ✔️ | ✔️ | ✔️ | ||
USART receive interrupt | ✔️ | ✔️ | ||||
Timer | ✔️ | ✔️ | ||||
SysTick delay | ✔️ | ✔️ | ||||
PWM | ✔️ | ✔️ | ||||
IWDG | ✔️ | ✔️ | ||||
WWDG | ✔️ | ✔️ | ||||
ADC (Regular single channel) | ✔️ | ✔️ | ||||
ADC (Injected multi channel) | ❌ | ✔️ | ||||
ADC (Interrupt) | ✔️ | ✔️ | ||||
ADC (External trigger by timer) | ✔️ | ✔️ | ||||
SPI (Master mode) | ✔️ | ✔️ | ||||
SPI (Slave mode) | ✔️ | ✔️ | ||||
I2C (LCD 1602) | ✔️ | ✔️ | ||||
I2C (EEPROM 24C256) | ✔️ | ✔️ | ||||
CRC | ✔️ | ✔️ |
STM32 Low Layer.
Examples | G431KB |
---|---|
ADC (Injected TRGO) | ✔️ |
UART Printf | ✔️ |
UART Printf (Ring buffer/kfifo) | ✔️ |
UART Printf (tiny) | ✔️ |
Check the code under the
User
folder in each project.
STM32 Hardware Abstraction Layer.
Examples | F103RB | F446RE | G431KB |
---|---|---|---|
Blinking LED | ✔️ |
Clone the repo:
git clone --recursive https://github.com/ziteh/stm32-examples.git
or
git clone https://github.com/ziteh/stm32-examples.git
git submodule update --init --recursive
- Install VSCode and PlatformIO IDE.
- Open example project folder (e.g. blink example) in VSCode.
- Selecte environment (STM32 board). Ref
- Build project and upload to STM32 board. Ref
Download STM32CubeIDE and open the project.
- STM32F103RB
- STM32F446RE
- STM32L432KC
- STM32G431KB
- STM32 Nucleo board user manual
My code is licensed under the MIT License. Other code is licensed under their own licenses (e.g., CMSIS under Apache 2.0, STM32 HAL/LL under BSD-3-Clause), which can be identified at each level of the folder or at the beginning of each file.