• Stars
    star
    117
  • Rank 295,668 (Top 6 %)
  • Language
    C
  • License
    MIT License
  • Created over 5 years ago
  • Updated about 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Bare metal STM32F4 examples for various modules

stm32f4-bare-metal

Bare metal STM32F4 examples to serve as starting points for projects. Educational purposes.

Some of the STM32F4xx family based processor headers are added in the include folder to get register locations. CMSIS library is added for a general support. No extra HAL libraries is used except the selected projects described below.

Common startup functions are located in the include/startup_stm32f407vgtx.s and include/system_stm32f4xx.c files to be included in all projects.

Installation

First, clone the project using git clone --recurse-submodules https://github.com/fcayci/stm32f4-bare-metal. The repository includes other repositories such as CMSIS as submodules under lib folder. You can alternatively clone the repository, then initialize and update the submodules with git submodule init and git submodule update commands.

Development

There are two options for development. First one is to use STM32CubeIDE from ST. Second one is the setup your own development environment. Both options are supported with relevant project settings or makefiles.

Option 1 - STM32CubeIDE

  • Download and install STM32CubeIDE. Select workspace on the root folder, then import existing projects to workspace. (File -> Import -> General -> Existing Projects into Workspace)
  • You do not need any additional tools. It comes with the compiler and debugger pre-installed.
  • Rest of the sections are for Option 2.

Option 2 - Custom development environment

  • Get toolchain (for compiler and binutils) from GNU Arm Embedded Toolchain
  • For windows only, install make tool. You can just get the make tool from gnuwin32. Alternatively you can install the minimalist GNU tools for windows from mingw and MSYS
  • For the programmer/debugger, you can use - stlink or OpenOCD. Though only stlink utility support is added.
  • You can use your favorite code editor to view/edit the contents. Here is an open source one: Visual Studio Code.

Compile

makefile contains necessary build scripts and compiler flags for all projects. Individual settings can be changed from local makefiles from projects such as blinky makefile

Browse into any directory and run make to compile.

cd projects/blinky
make

If everything is setup correctly, you should see the completed message.

Cleaning blinky
Building blinky.c
   text    data     bss     dec     hex filename
    852	      8	   1568	   2428	    97c	blinky.elf
Successfully finished...

If you see any errors about command not found, make sure the toolchain binaries are in your PATH. On Windows check the Environment Variables for your account. On Linux/macOS run echo $PATH to verify your installation.

Program

Run make burn to program the chip.

...
.. Flash written and verified! jolly good!

Install the ST LINK drivers if you cannot see your board when make burn is run.

Disassemble

Run make disass / make disass-all to disassamble.

Debug

In order to debug your code, connect your board to the PC, run st-util (comes with stlink utility) from one terminal, and from another terminal within the project directory run make debug. You can then use general gdb commands to browse through the code.

Projects

  • blinky - Good old blink LEDs example
  • clock - Shows how to change clock frequencies on the fly
  • math - A simple sine function to test math library operation
  • systick - Blinks LEDs using systick timer.
  • timer - Blinks LEDs one at a time using the Timer module and Timer interrupt
  • pwm - Fades an LED using pwm functionality using Timer module
  • external - External interrupt example using the on-board push-button
  • dac - On-chip digital to analog converter operation
  • dac-timer - On-chip digital to analog converter operation with timer trigger
  • uart - UART example to show how to send data over
  • uart-tx-int - UART example with tx interrupt
  • uart-dma - UART tx example with DMA transfer
  • spi - SPI example that is customized for on-board motion sensor (lis302dl version)
  • i2c - I2C example that communicates with the on-board Audio DAC
  • wwdg - Window Watchdog example
  • itm - Message sending through CoreSight ITM port 0
  • dma - Example DMA transfer using memory-to-memory mode
  • sleepy - Low Power mode operations (sleep and stop)
  • flash - Example to show how to write/erase internal flash memory
  • i2s-beep - I2S example that plays a couple notes using the internal beep generator from on-board Audio DAC through audio jack. It does not send any I2S data.
  • pendsv - Example project on a non-OS use of PendSV exception

More Repositories

1

stm32f1-bare-metal

Bare metal STM32F1 examples for various modules
C
59
star
2

vhdl-hdmi-out

HDMI Out VHDL code for 7-series Xilinx FPGAs
VHDL
53
star
3

vhdl-digital-design

VHDL code examples for a digital design course
VHDL
20
star
4

stm32g0

STM32G0 examples
C
15
star
5

vhdl-axis-uart

UART to AXI Stream interface written in VHDL
VHDL
15
star
6

STM32F4-ChibiOS

ChibiOS/RT examples running on STM32F4 Discovery board
C
12
star
7

sv-digital-design

SystemVerilog examples for a digital design course
SystemVerilog
11
star
8

vhdl-display-simulator

Screen Display Simulator written in VHDL and JS
VHDL
8
star
9

stm32f4-c-template

C template for an STM32F407-based board
C
7
star
10

stm32f1-assembly

Assembly template for an STM32F107-based board.
Assembly
6
star
11

stm32f4-assembly

Assembly template for STM32F4 Discovery board with STM32F407VG chip
Assembly
5
star
12

xilinx_vga_fsl_ip_core

Example VGA IP Core using FSL for Xilinx FPGAs
VHDL
5
star
13

LM3S9B92-EVALBOT

The libraries and projects for TI's Evalbot
C
5
star
14

vhdl-conv2d

end to end 2d image convolution with VHDL
VHDL
5
star
15

stm32f1-rtos

Example project for running the CMSIS-RTOS2 on an STM32F107-based board using GNU Arm toolchain
C
4
star
16

stm32f1-uGFX

TFT example code using uGFX library with ILI9341 driver - 8-bit parallel type 1 mode
C
3
star
17

xilinx-ip-repo

My Xilinx IP cores to be used in Vivado Design Suite
VHDL
2
star
18

stm32f1-c-template

C template for an STM32F107-based board
C
2
star
19

xilinx_push_button_interrupt

An interrupt example c code for push buttons for Xilinx EDK project
C
1
star
20

xilinx_vga_framebuffer_ip_core

VGA IP Core using a dual-port BRAM as a frame buffer (shared BRAM access)
VHDL
1
star
21

dragonfly

Yet another quadcopter
C
1
star
22

udp-stream

Simple UDP stream implementation using sockets.
C++
1
star
23

dotfiles

my dotfiles
Vim Script
1
star
24

stm32f4stick-software

Software files for a small STM32F405/STM32F401 based development board
C
1
star
25

stm32f1-assembly-projects

Assembly
1
star
26

stm32f4stick-hardware

Hardware files for a small STM32F405/STM32F401 based development board
1
star
27

simple-flask-app

Simple flask app
Python
1
star