PlatformIO 開發STM32 (Arduino框架)


創建項目

BoardSTM32F103C8(20k RAM.64k Flash)(Generic)

硬件接線及跳線

跳線

使用Jlink無需配置boot引腳

建議都默認為0boot啟動模式參考文檔

硬件接線

JLINK STM32 Board
(Reset) (R)
(3.3v) (3.3v)
(SWCLK) (DCLK)
(SWDIO) (DIO)
(GND) (GND)

JLink驅動安裝包及其手冊

測試代碼

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!");
}

引腳筆記

  • GND3.3v都是內部相通的。3.3v直接給單片機供電,5v接口會通過LDO穩壓芯片給單片機供電。
  • microusb只能供電不能下載。
  • 另一端swd下載接口,和跳線帽搭配使用 ,JlinkSTlink都可以。
  • 跳線后可串口下載(PA9 PA10),建議swd,方便測試。
  • PC13連指示燈。
  • B12`PB15`是`SPI2`,`PA4`7SPI1, PA9 PA10串口1PA2 PA3串口2,PB10 PB11串口3PB6~PB9一般可以用於pwm輸出,對應TIM4PC13~15 用於時鍾相關。
  • VB用於后備電源供電。
  • ADC接口:PA0~PA7,PB0 PB1盡量別用PB3 PB4 PA15,它們和下載口相關。

參考教程

stm32開發新方式-platformio的IDE (smslit.cn)

PlatformIO IDE(VSCode) - stm32cube 框架的工程 - 知乎 (zhihu.com)

stm32開發新方式-platformio (smslit.cn)


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM