創建項目
Board
選 STM32F103C8(20k RAM.64k Flash)(Generic)
硬件接線及跳線
跳線
使用Jlink
無需配置boot
引腳
建議都默認為0
,boot啟動模式參考文檔
硬件接線
JLINK | STM32 Board |
---|---|
(Reset) | (R) |
(3.3v) | (3.3v) |
(SWCLK) | (DCLK) |
(SWDIO) | (DIO) |
(GND) | (GND) |
測試代碼
platformio.ini
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
[env:genericSTM32F103C8]
platform = ststm32
board = genericSTM32F103C8
framework = arduino
; board_build.f_cpu = 72000000L
upload_protocol = jlink
main.cpp
/*
* @Author: Dapenson
* @Date: 2022-03-28 15:20:38
* @LastEditors: Dapenson
* @LastEditTime: 2022-03-28 16:36:05
* @FilePath: \F103EnvTest\src\main.cpp
* @Description:
*
* Copyright (c) 2022 by Dapenson, All Rights Reserved.
*/
#include <Arduino.h>
const int ledPin = PC13;
void setup()
{
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
}
void loop()
{
digitalWrite(ledPin, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(ledPin, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
Serial.println("Done!");
}
引腳筆記
GND
,3.3v
都是內部相通的。3.3v
直接給單片機供電,5v
接口會通過LDO穩壓芯片給單片機供電。microusb
只能供電不能下載。- 另一端
swd
下載接口,和跳線帽搭配使用 ,Jlink
,STlink
都可以。 - 跳線后可串口下載(
PA9
PA10
),建議swd
,方便測試。 PC13
連指示燈。B12
`PB15`是`SPI2`,`PA4`7
是SPI1
,PA9
PA10
是串口1
,PA2
PA3
是串口2
,PB10
PB11
是串口3
,PB6~PB9
一般可以用於pwm輸出
,對應TIM4
。PC13~15
用於時鍾相關。VB
用於后備電源供電。ADC
接口:PA0~PA7,PB0 PB1
。盡量別用PB3 PB4 PA15
,它們和下載口相關。
參考教程
stm32開發新方式-platformio的IDE (smslit.cn)