/practice-mcu-bare-metal-stm32f030

A bare metal (register level) STM32F030C8T6/STM32F030 MCU program written in pure C without any IDE, SDK, HAL or library, the only tool required is the GCC compiler.

Primary LanguageCMozilla Public License 2.0MPL-2.0

MCU STM32F030C8T6 Bare-metal in C

EN | 中文

A bare metal (register level) STM32F030C8T6/STM32F030 MCU program written in pure C without any IDE, SDK, HAL or library, the only tool required is the GCC compiler.Implement basic input and output, timer, serial communication, etc. by directly reading and writing registers of hardware.

stm32f030 bare-metal C

Routines

  • test_set_clock: PLL and SYSCLK
  • test_blink: GPIO output
  • test_button: GPIO input
  • test_systick: SysTick
  • test_uart: UART communication
  • test_button_interrupt: GPIO interrupt
  • test_timer: general timer
  • test_timer_interrupt: general timer with interrupt
  • test_eeprom: I2C peripheral
  • test_dma: DMA memcpy
  • test_dma_interrupt: DMA with interrupt
stm32f030.mp4

Demo video

Wires

  • PC13: builtin LED -
  • PB9: external LED +
  • PB0: button 0 (the another button pin connect to GND)
  • PB1: button 1 (the another button pin connect to GND)
  • PA9: USART1_TX -> CP2012 RX
  • PA10: USART1_RX -> CP2012 TX
  • PB6: SCL -> EEPROM SCL
  • PB7: SDA -> EEPROM SDA

Compile

Install arm-none-eabi-gcc on your platform first, then run:

$ ./build.sh

Flash

Connect the MCU to your computer using the CMSIS_DAP Link and then run:

$ ./flash.sh

Debug

$ ./server-gdb-server.sh

then open another terminal, and run:

$ ./start-gdb-client-with-svd.sh

Reference Documents

Hardware description and register structure and value description documentations:

Thanks:

Rust language version

This project is also implemented in Rust by the author, for those interested please check out MCU STM32F103C8T6 Bare-metal in Rust