-
File
>New
>C Project
- Set project name
- Choose
Ac6 STM32 MCU GCC
-
Target Configuration
- Go to
Mcu
tab - Series:
STM32F1
- Mcu:
STM32F103C8Tx
- Go to
-
Firmware Configuration
- Choose
Cube HAL
- Check
Extract all firmware in separate folder
- Choose
As static external libraries
- Click
Finish
- Choose
-
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/
$ brew install stlink
$ st-flash write hello_world.bin 0x8000000
-
Remove all jumpers from Nucleo CN2
-
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:
BOOT1 | BOOT0 | Mode |
---|---|---|
X | 0 | Flash memory |
0 | 1 | Bootloader |
1 | 1 | Embedded SRAM |
- Top: BOOT0
- Bottom: BOOT1
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
# create symbolic link so we don't need to download duplicates
ln -s ~/.ac6/SW4STM32/firmwares ~/STM32Cube/Repository
In Project Window:
[Right-click project] > Options for Target > C/C++ > Misc Controls
--C99 --CPP11
[Right-click
main.c
]
main.cpp
C++ Source File
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
- https://isocpp.org/wiki/faq/mixing-c-and-cpp#cpp-calls-c
- https://en.wikipedia.org/wiki/Name_mangling
- https://stackoverflow.com/questions/36504275/using-c-names-in-c
- https://stackoverflow.com/questions/2168241/is-it-required-to-add-extern-c-in-source-file-also
Note: Open
.map
file (as a text file) to see linker process