创建项目
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)