Skip to content

STM32 microcontrollers exploration. Covers the basics (linker scripts, assembly, GPIO, interrupts, clocks) and some other fun stuff (FreeRTOS, Rust).

License

Notifications You must be signed in to change notification settings

aaronhktan/stm32-exploration

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

STM32 Exploration

A set of code examples and comments to teach myself a bit more about microcontrollers.

Info

I've adapted most of the code by following along Vivonomicon's STM32 examples.

The additions to the code presented in the examples are:

  • Porting the examples to other boards (specifically, Nucleo STM32F446RET6)
  • Adding comments for parts that were new to me or to explain certain aspects in more detail
  • Modifications and additions to make the Makefile support multiple targets (F031K6 and F446RE)

Contents

This repository contains code samples and examples to understand aspects of embedded programming from first principles.

  • 01-basic contains linker scripts and ARM Thumb assembly.
  • 02-main contains vector tables and C. It also explores the ELF binary format.
  • 03-gpio takes input via a button and toggles an LED with memory-mapped IO.
  • 04-interrupt does the same thing as 03-gpio but uses interrupts using the NVIC and EXTI peripherals.
  • 05-timer explores the clock peripherals, specifically using the 16MHz HSI oscillator to drive a PLL and core clock (HCLK).
  • 06-freertos explores configuration of and using FreeRTOS to blink LEDs at intervals.
  • 07-rust generates a peripheral access crate using svd2rust, and then blinks LEDs with Rust.

Build and run

Development was done on macOS, so all the makefiles work on macOS. I have not verified that they work on Linux.

To build, make <target-name> should work, where target-name is either f031k6 or f446re.

To run,

  • Run st-util.
  • Type arm-none-eabi-gdb <output-name.elf>.
  • In GDB, target extended-remote :4242.
  • load, and then continue.

For the Rust mini-project, build with cargo build in the appropriate rust-blink directory, and run with openocd and cargo run.

Future

  • I intend to continue learning more about embedded programming with this series! A few fundamentals that I haven't had the time to include the basic communication peripherals (UART, SPI, I2C).

About

STM32 microcontrollers exploration. Covers the basics (linker scripts, assembly, GPIO, interrupts, clocks) and some other fun stuff (FreeRTOS, Rust).

Topics

Resources

License

Stars

Watchers

Forks