Skip to content

Latest commit

 

History

History
executable file
·
124 lines (79 loc) · 3.45 KB

File metadata and controls

executable file
·
124 lines (79 loc) · 3.45 KB

STM32F103C8T6 (Blue Pill)

Documents

Pinout

Pinout Pinout

Schematic

Schematic Source


Creating new project in SW4STM32

  1. File > New > C Project

    • Set project name
    • Choose Ac6 STM32 MCU GCC
  2. Target Configuration

    • Go to Mcu tab
    • Series: STM32F1
    • Mcu: STM32F103C8Tx
  3. Firmware Configuration

    • Choose Cube HAL
    • Check Extract all firmware in separate folder
    • Choose As static external libraries
    • Click Finish
  4. Replace startup file

    • In some cases, the correct startup file is not copied in automatically by SW4STM32. This will cause interrupt vector functions to not work.
    • Copy ~/.ac6/SW4STM32/firmwares/STM32Cube_FW_F1_V1.6.0/Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f103x6.s to ${project_dir}/startup/

Program with st-flash in command line

$ brew install stlink
$ st-flash write hello_world.bin 0x8000000

Using Nucleo Board as ST-Link programmer

  1. Remove all jumpers from Nucleo CN2

  2. Connect the following:

Function Nucleo Board Blue Pill
SWCLK Pin 2 (CN4) Pin 2 (Debug)
SWDIO Pin 4 (CN4) Pin 3 (Debug)
RESET Pin 5 (CN4) R (I/O)
3V3 3V3 (CN6) Pin 4 (Debug)
GND GND (CN6) Pin 1 (Debug)

More details:

Boot Modes

BOOT1 BOOT0 Mode
X 0 Flash memory
0 1 Bootloader
1 1 Embedded SRAM

  • Top: BOOT0
  • Bottom: BOOT1

Fix "Cannot connect to ST-LINK!" error

http://www.kerrywong.com/2012/08/02/the-dreaded-cannot-connect-to-st-link-error-message/

https://www.youtube.com/watch?v=jEz0C2bT2M0&app=desktop

https://forum.sparkfun.com/viewtopic.php?f=18&t=35249#wrap

https://electronics.stackexchange.com/questions/230036/problems-connecting-st-link-v2-and-stm32f4-discovery-board

Symbolic link for drivers (STM32CubeMX and SW4STM32)

# create symbolic link so we don't need to download duplicates
ln -s ~/.ac6/SW4STM32/firmwares ~/STM32Cube/Repository

Creating C++ project in Keil uVision 5

In Project Window:

[Right-click project] > Options for Target > C/C++ > Misc Controls

--C99 --CPP11

[Right-click main.c]

main.cpp

C++ Source File

Resources

https://electronics.stackexchange.com/questions/279524/stm32-interrupts-and-c-dont-go-well-together http://www.openstm32.org/forumthread2509 https://stackoverflow.com/questions/35288808/first-project-for-stm32-with-hal-in-c https://community.st.com/thread/39920-what-are-your-experiences-of-c-on-this-platform http://www.keil.com/support/docs/3869.htm

C++ Name Mangling

Note: Open .map file (as a text file) to see linker process