Skip to content

The ARM Cortex-M4 processor bare metal project with UART implementation

Notifications You must be signed in to change notification settings

Risheng1128/cm4bm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cm4bm

The ARM Cortex-M4 processor bare metal project with UART implementation

Build

cm4bm dependents on some third-party packages to build code and burn into processor like ARM GNU Toolchain and stlink. Therefore, before using the project, we need to install these packages.

Install ARM GNU Toolchain:

$ sudo apt-get update
$ sudo apt-get -y install gcc-arm-none-eabi

Install stlink:

$ sudo apt-get update
$ sudo apt-get -y install stlink-tools

Install OpenOCD:

$ sudo apt install openocd

Build cm4bm:

$ make

Burn the code into processor:

$ make upload

Generate the disassembly file:

$ make disassembly

Debug

The toolchain downloaded using the command sudo apt-get -y install gcc-arm-none-eabi does not include arm-none-eabi-gdb. Therefore, it needs to be added separately, which can be downloaded from Arm GNU Toolchain Downloads. Then. adding arm-none-eabi-gdb into path /usr/bin/.

In cm4bm, it uses cortex-debug to trace the source code and find the bugs. Before using cortex-debug, the following libraries that are necessaty for arm-none-eabi-gdb need to be installed.

$ sudo apt-get install libncursesw5
$ sudo apt install python3.8

Test

Install putty to communicate with the board:

$ sudo apt-get install putty

GPIO setting

Set PD8 and PD9 as USART3 Tx and USART3 Rx respectively.

  • PD8 setup:
    GPIO Setting Mode
    GPIOD_MODE Alternate function mode
    GPIOD_OSPEEDR Low Speed
    GPIOD_PUPDR No Pull-up & Pull-down
    GPIOD_OTYPER Push-Pull
    GPIOD_AFRH AF7 (USART3 Tx)
  • PD9 setup:
    GPIO Setting Mode
    GPIOD_MODE Alternate function mode
    GPIOD_OSPEEDR Low Speed
    GPIOD_PUPDR No Pull-up & Pull-down
    GPIOD_OTYPER Push-Pull
    GPIOD_AFRH AF7 (USART3 Rx)

USART setup

USART3 config Setting
F_CLK 8MHz (STM32F303ZE default clock)
USART3_Mode Tx/Rx Enable
USART3_Parity Parity disable
USART3_StopBits 1
USART3_WordLen 8
USART3_Baud 38400
USART3_HW_FLOW None
Oversampling 16

Reference

About

The ARM Cortex-M4 processor bare metal project with UART implementation

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published