Hi! I am a beginner and trying to program the Blue Pill Module using Bare Metal (Register Programming). This repository is only meant for learning purpose. Please let me know if there is any mistake and if possible how to resolve it. For any suggestions you can connect with me on LinkedIn: Shrey Shah
Few GitHub Repositories that I referred to during development phase:
- Basic Repository for understanding the Registers present in Blue Pill Development Module
- Created basic source files to use Registers for controlling purpose
Projects/Template
is the template which can be used as reference while creating New Project
BareMetal
: Consists of all the Register Address Mapping along with Driver Source CodeProjects
: Consists of User Specific ApplicationReference_Docs
: All the Reference Documentation relevant to the topic
STM32F103C_Reference_Manual.pdf
Specification | Details | Comments |
---|---|---|
Processor | ARM Cortex-M3 | Single Core |
Clock Frequency | Min: 8MHz | HSI: 8MHz |
Max: 72MHz | HSE: 8MHz | |
Flash | Size: 64kB | Address: 0x08000000 |
SRAM | Size: 20kB | Address: 0x20000000 |
Vector Table | 76 |
---|---|
ARM Cortex-M3 IRQ | 11 |
STM32F103C8T6 IRQ | 59 |
Reserved | 6 |
- Power ON
- Stack Pointer (SP)
- Points to the top of SRAM (Vector Table Offset:
0x00
)
- Points to the top of SRAM (Vector Table Offset:
Reset_Handler()
is called- Vector Table Offset:
0x01
- Initialization Steps:
- Copy the
.data
section from FLASH to SRAM- Note:
.data
refers to initialized variables.
- Note:
- Initialize the
.bss
section to0
- Note:
.bss
refers to uninitialized variables.
- Note:
- Call the Main function
- Copy the
- Vector Table Offset:
STM32F103C8T6
├── BareMetal # Main Bare Metal Codes
│ ├── Core ## Core Files: Register Structure + Debugging Configurations
│ └── Driver ## Driver Files: RCC, GPIO, USART, I2C, SSD1306 OLED, etc.
├── Projects # User Specific Application
│ ├── GPIO ## GPIO Application
│ └── Template ## Reference Template
├── README.md # Documentation
└── Reference_Docs # Contains the Reference Documentations useful for STM32F103
Driver
├── ADC
│ ├── Inc
│ │ └── adc.h
│ └── Src
│ └── adc.c
├── bare_metal.h
├── DMA
│ ├── Inc
│ │ └── dma.h
│ └── Src
│ └── dma.c
├── EXTI
│ ├── Inc
│ │ ├── exti.h
│ │ └── nvic.h
│ └── Src
│ └── exti.c
├── GPIO
│ ├── Inc
│ │ ├── gpio_config.h
│ │ └── gpio.h
│ └── Src
│ └── gpio.c
├── I2C
│ ├── Inc
│ │ ├── i2c_config.h
│ │ ├── i2c_dma.h
│ │ ├── i2c.h
│ │ └── i2c_irq.h
│ └── Src
│ ├── i2c.c
│ ├── i2c_config.c
│ ├── i2c_dma.c
│ └── i2c_irq.c
├── PWM
│ ├── Inc
│ │ ├── pwm_config.h
│ │ └── pwm.h
│ └── Src
│ ├── pwm.c
│ └── pwm_config.c
├── RCC
│ ├── Inc
│ │ ├── rcc_config.h
│ │ └── rcc.h
│ └── Src
│ ├── rcc.c
│ └── rcc_config.c
├── reg_map.h
├── SSD1306
│ ├── Inc
│ │ ├── ssd1306_font.h
│ │ └── ssd1306.h
│ └── Src
│ └── ssd1306.c
├── SysTick
│ ├── Inc
│ │ ├── systick_config.h
│ │ └── systick.h
│ └── Src
│ └── systick.c
├── Timer
│ ├── Inc
│ │ ├── timer_config.h
│ │ └── timer.h
│ └── Src
│ └── timer.c
└── USART
├── Inc
│ └── usart.h
└── Src
└── usart.c
✅ Ensure that all dependent header files (.h
) are included within the corresponding .h
file, not inside the .c
source file.
- The build system uses the
-M
flag with the compiler to automatically track dependencies. -M
only processes included headers visible through.h
files at compile time- Missing or misplaced includes (inside
.c
only) will break dependency resolution, leading to incomplete or incorrect builds
- If a
.c
file depends on an external header, that header must be included in the corresponding.h
file - This ensures proper dependency extraction, reliable incremental builds, and fewer surprises
<Project_Name>
├── Inc
│ └── main.h
├── Makefile
├── Src
│ └── main.c
└── Startup
├── stm32f1_ls.ld
└── stm32f1_startup.c
make all
: Compiles all the relevant files and generates the executable in a "Build" Directorymake clean
: Removes the "Build" Directorymake flash
: Flashes .bin file at Flash Address (0x080000000
)make erase_flash
: Erases the Flash Memory of Blue Pill Modulemake debug
: Creates the .json debug related files for Arm-Cortex Debug (VS Code) inside a .vscode directorymake replace_makefiles
: Updates all Makefiles inside "Project" directory with current Makefilemake info
: Provides information about the connected STM32 devicemake dependency
: Lists the relevant files required for compilation & stores it inBuild/dependency.mk
for dynamic dependency tracking