STM32F303K8 test and example projects for PWM control and embedded debugging.
I2C connectivity example using STM32F303K8 I2C 1. Demonstrates two-way communication on the I2C bus with an external module.
Configuration
- I2C1 configured on:
- PB7 (SDA)
- PB6 (SCL)
- Status LED:
- PB3 (GPIO OUT)
PWM fade control example using STM32F303K8 Timer 1. Demonstrates smooth LED fading using PWM duty cycle modulation.
Features:
- Timer 1 PWM on PA8 (CH1) with an LED
- C++
PWMFaderclass for encapsulated fade control - 4 PWM channels configured:
- Channels 1-2: 2 second fade cycle
- Channels 3-4: 200ms fade cycle
- PB3 GPIO toggle for debug LED
Key Files:
Core/Src/PWMFader.cpp- PWM fading implementationCore/Inc/PWMFader.h- PWM fader class definitionCore/Src/main.c- Main application
Embedded test and debug program with UART serial logging capabilities.
Features:
- Serial debug logging via UART2 (38400 baud)
Log.cppclass for formatted string output- Program loop with configurable iterations
- GPIO input reading for test control
Testsclass for executing test code
Build using STM32CubeIDE
In the stm32f303k8-test project, a Log.cpp class sends formatted string data to the UART2 port through HAL_UART_Transmit().
UART2 must be enabled through the .ioc file in async mode. This generates pin configuration in main.c which should be manually mapped to main.cpp (the IDE generates to main.c by default).
To view serial data:
- Open Command Shell Console from the Console tool window
- Create a mapping for the COM port (e.g. COM3)
- Set parameters: BaudRate = 38400, Stop bits = 1, Parity = none
Serial output streams in both debug and run modes.
When the .ioc file is updated with pin configuration changes, STM32CubeIDE only generates code to main.c. For C++ projects:
- Copy entire main.c to main.cpp
- User code sections are preserved
- Project compiles as C++
Program logic is separated and called through Program::Run().