本帖最后由 袁胜富 于 2024-5-5 21:04 编辑
#申请原创#[url=home.php?mod=space&uid=760190]@21小跑堂 [/url]
一、安装PlatformIO
1.安装VSCode,在拓展找到PlatformIO,安装。
2.安装好后创建工程
STM32F411VET6是没有JSON配置文件的,需要自己制作
{
"build": {
"core": "stm32",
"cpu": "cortex-m4",
"extra_flags": "-DSTM32F411xE -DSTM32F4xx",
"f_cpu": "120000000L",
"mcu": "stm32f411vet6",
"product_line": "STM32F411xE",
"variant": "STM32F4xx/F411V(C-E)T"
},
"debug": {
"jlink_device": "STM32F411VE",
"openocd_target": "stm32f4x",
"svd_path": "STM32F411xx.svd"
},
"frameworks": [
"arduino",
"cmsis",
"stm32cube",
"libopencm3"
],
"name": "STM32F411VE (128k RAM. 512k Flash)",
"upload": {
"maximum_ram_size": 131072,
"maximum_size": 524288,
"protocol": "serial",
"protocols": [
"blackmagic",
"dfu",
"jlink",
"serial",
"stlink",
"cmsis-dap"
]
},
"url": "https://www.st.com/en/microcontrollers-microprocessors/stm32f411re.html",
"vendor": "Generic"
}
支持Arduino开发和DAPLink下载。
还要修改链接脚本,时钟,引脚复用等,下图所示
以上文件均会提供附件。
如果要支持USART3,UART4,UART5需要修改启动文件(startup_stm32f411xe.s)和stm32f411xe.h的中断枚举
新建工程完成后,需要配置下载协议为cmsis-dap
二、测试代码
#include<Arduino.h>
#define LED2 PE6
#define LED3 PE5
HardwareSerialSerial1(USART1);
voidsetup() {
// put your setup code here, to run once:
pinMode(LED2,OUTPUT);
pinMode(LED3,OUTPUT);
Serial1.begin(115200);
}
voidloop() {
// put your main code here, to run repeatedly:
digitalToggle(LED2);
digitalToggle(LED3);
Serial1.println("Hello World");
delay(500);
}
三、展示
|