Skip to content

This project demonstrates how to **blink an onboard LED** using the **STM32F446RE** microcontroller through **bare-metal programming** in **Keil µVision**. It directly accesses **RCC** (clock) and **GPIO** registers using the CMSIS header file `stm32f446xx.h` — no HAL or CubeMX used.

Notifications You must be signed in to change notification settings

asathiskumar98-byte/STM32F446RE-LED-Blink-Bare-Metal-Programming-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

💡 STM32F446RE – LED Blink (Bare Metal Programming)

📘 Project Overview

This project demonstrates how to blink an onboard LED using the STM32F446RE microcontroller through bare-metal programming in Keil µVision.
It directly accesses RCC (clock) and GPIO registers using the CMSIS header file stm32f446xx.h — no HAL or CubeMX used.


⚙️ Hardware Details

Microcontroller: STM32F446RE
IDE: Keil µVision
Programming Method: Bare Metal (Register-level)
LED Pin: PA5 (Onboard LED – Nucleo Board)


🔩 Code Explanation

1️⃣ Enable HSI Clock

RCC->CR |= (1<<0);   // Enable internal high-speed oscillator (HSI)

2️⃣ Enable GPIOA Clock

RCC->AHB1ENR |= (1<<0);   // Enable clock for GPIOA

3️⃣ Configure GPIOA Pin 5 as Output

GPIOA->MODER |= (1<<10);   // Set PA5 as General Purpose Output
GPIOA->OTYPER = 0x0000;    // Push-pull output type
GPIOA->OSPEEDR = 0x00000000; // Low speed

4️⃣ Toggle LED with Software Delay

while(1)
{
	GPIOA->ODR |= (1<<5);   // LED ON
	delay(500000); delay(500000);

	GPIOA->ODR &= ~(1<<5);  // LED OFF
	delay(500000); delay(500000);
}

🕹️ Output Behavior

The onboard LED (PA5) will blink continuously with a fixed delay. Each delay cycle is generated by a simple software loop, which isn’t timing accurate but sufficient for demonstration.

🧠 Key Learning Points

Understanding RCC (Reset and Clock Control) registers

Configuring GPIO pins directly using MODER, OTYPER, OSPEEDR, and ODR registers

Implementing software delays without using timers

🚀 Future Enhancements

Replace software delay with Timer-based delay (using TIM2 or SysTick)

Add push-button input for manual LED control

Extend to multiple GPIO pins for pattern-based LED blinking

About

This project demonstrates how to **blink an onboard LED** using the **STM32F446RE** microcontroller through **bare-metal programming** in **Keil µVision**. It directly accesses **RCC** (clock) and **GPIO** registers using the CMSIS header file `stm32f446xx.h` — no HAL or CubeMX used.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages