RTC-wakeup blink demo for STM32F401CCU6. On each RTC wakeup event it flashes the PC13 LED three times rapidly and prints the current date and time via USART6 at 115200 baud. Register-level, no HAL.
- Register-level, bare-metal firmware (no HAL, no CMSIS-DSP)
- System clock 100 MHz from HSE 25 MHz via PLL (25 / 15 x 120 / 2)
- RTC with LSE oscillator, wakeup timer period ~1 s
- Three fast LED flashes (30 ms each toggle) on each RTC wakeup
- USART6 output: date and time in
DD.MM.YYYY HH:MM:SSformat at 115200 baud - Instruction & data cache enabled, prefetch active, 2 wait states
| Component | Detail |
|---|---|
| MCU | STM32F401CCU6 (Cortex-M4, 256 KB Flash, 64 KB RAM) |
| Clock | HSE 25 MHz -> PLL -> 100 MHz SYSCLK |
| Cache | 2 WS, ICache + DCache + prefetch |
| LED | PC13 (on-board), push-pull output |
| RTC | LSE 32768 Hz, wakeup timer |
| UART | USART6 on PA11, 115200 baud, 8N1 |
| Debug | SWD on PA13/PA14 |
- ARM GCC toolchain (
arm-none-eabi-gcc13.x or later) - GNU Make
- curl, unzip
makeAll third-party files (CMSIS headers, SVD, IDE startup files) are downloaded automatically at build time.
Output in build/: project.elf, project.hex, project.bin.
| Target | Description |
|---|---|
make |
Download deps + build |
make download_cmsis |
Download CMSIS core + STM32F4xx headers |
make download_svd |
Download STM32F401.svd |
make download_iar_startup |
Download IAR startup file |
make download_mdk_startup |
Download MDK-ARM startup file |
make download_licenses |
Download third-party license files |
make download |
Download all of the above |
make program |
Flash via ST-LINK |
make jprogram |
Flash via J-Link |
make clean |
Remove build artifacts |
make clean_all |
Remove build artifacts + all downloaded files |
Important: All third-party dependencies (CMSIS headers, startup files, SVD) are downloaded at build time via
make. Runmake downloadfrom the project root before opening the project in any IDE. Without this step the IDE project will not compile.
Each IDE folder has a README with setup and CLI build instructions.
| IDE | Project | CLI Tool |
|---|---|---|
| SEGGER Embedded Studio | ide/SES/Project.emProject |
emBuild.exe |
| Keil MDK-ARM | ide/MDK-ARM/Project.uvprojx |
UV4.exe |
| IAR EWARM | ide/EWARM/Project.eww |
IarBuild.exe |
.
+-- main.c Application + init
+-- main.h Macros, clock tree, GPIO helpers
+-- crt0.c __libc_init_array stub (SES bundled GCC)
+-- Makefile GCC build + download targets
+-- STM32F401CCUX_FLASH.ld GNU linker script
+-- LICENSE MIT License + third-party notice
+-- stm32f401cc.jflash J-Flash project
+-- project.jdebug J-Link debugger project
+-- CMSIS/ Downloaded at build time (gitignored)
+ +-- core/ ARM CMSIS headers + LICENSE.txt
+ +-- device/ STM32F4xx headers + startup + LICENSE.md
+-- ide/
+-- EWARM/ IAR Embedded Workbench project
+-- MDK-ARM/ Keil MDK-ARM project
+-- SES/ SEGGER Embedded Studio project
HSE 25 MHz
|
v
PLLM = 15 25 / 15 = 1.667 MHz (VCO input)
PLLN = 120 1.667 x 120 = 200 MHz (VCO output)
PLLP = /2 200 / 2 = 100 MHz
|
v
SYSCLK = 100 MHz
|
+-- AHB1 (HPRE = /1) -> HCLK = 100 MHz
| +-- APB1 (PPRE1 = /2) -> PCLK1 = 50 MHz
| +-- APB2 (PPRE2 = /1) -> PCLK2 = 100 MHz
| +-- SysTick timer (AHB/8 = 12.5 MHz)
|
+-- FLASH: 2 WS, ICache + DCache + Prefetch ON
| Parameter | Value |
|---|---|
| Clock source | LSE (32768 Hz) |
| Asynchronous prescaler (PREDIV_A) | 127 |
| Synchronous prescaler (PREDIV_S) | 255 |
| Wakeup timer clock | RTCCLK/16 = 2048 Hz (WUCKSEL = 000) |
| Wakeup timer reload (WUTR) | 2047 |
| Wakeup interval | ~1 second |
Reset -> main()
|
init_sys() RCC: HSE -> PLL -> 100 MHz
| FLASH: 2 WS, cache + prefetch
| PWR: enable backup domain
| RCC: LSE ON, RTC clock = LSE
| RTC: init time/date, wakeup timer
| SysTick: start (for DELAY_MS)
|
init_gpio() GPIOA: USART6 TX (AF8)
| GPIOC: PC13 output (LED)
|
init_usart(115200) USART6: 115200 baud, TX only
|
loop:
wait RTC wakeup flag (WUTF)
capture time/date (TR/DR)
6 toggles of PC13 (3 full flashes, 30 ms each)
u_put_bcd(field) + separator per toggle
-> USART6: "DD.MM.YYYY HH:MM:SS\n"
Source code is MIT (see LICENSE). Third-party components downloaded at build time are covered by their own licenses (see LICENSE for details).
