A set of code examples and comments to teach myself a bit more about microcontrollers.
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)
This repository contains code samples and examples to understand aspects of embedded programming from first principles.
01-basiccontains linker scripts and ARM Thumb assembly.02-maincontains vector tables and C. It also explores the ELF binary format.03-gpiotakes input via a button and toggles an LED with memory-mapped IO.04-interruptdoes the same thing as03-gpiobut uses interrupts using the NVIC and EXTI peripherals.05-timerexplores the clock peripherals, specifically using the 16MHz HSI oscillator to drive a PLL and core clock (HCLK).06-freertosexplores configuration of and using FreeRTOS to blink LEDs at intervals.07-rustgenerates a peripheral access crate usingsvd2rust, and then blinks LEDs with Rust.
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 thencontinue.
For the Rust mini-project, build with cargo build in the appropriate rust-blink directory, and run with openocd and cargo run.
- 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).