Arduino_STM32整理贴
Arduion-STM32
stm32duino 让stm32 在arduino中使用
源代码:https://github.com/stm32duino/Arduino_Core_STM32
busybox文件位置 stm32duino 下有个stm32tool 项目,内含有busybox.exe
使用usb转TTL烧写
使用 PA9 PA10 端口
PA9接 RX ,PA10接 TX ,3.3接 STM32板子的3.3V(面包板上发现5V更稳定,有时3.3无法上传),GND接GND
usb 转ttl TX->PA10 RX ->PA9 GND->GND 3.3V ->3.3V
指定串口管脚用法示例
使用ST官方Arduino库,可在STM32全系列开发板上进行如下实验。
注意:实例化串口对象需要加数字编号(Serialx中的x是串口编号,取值是1,2……):
HardwareSerial Serialx(PA10, PA9); //将Serialx(x=1-4)串口x的管脚,一定要带编号,如:Serial1
强调一下:不能实例化默认的串口:HardwareSerial Serial(PA10, PA9)
原文链接:https://blog.csdn.net/qcmyqcmy/article/details/128393652
#include <HardwareSerial.h>HardwareSerial Serial1(PA10,PA9);void setup() {Serial1.begin(115200);pinMode(PC13, OUTPUT);Serial1.println("hello");}// the loop function runs over and over again forevervoid loop() {Serial2.println("hello world");digitalWrite(PC13, HIGH); // turn the LED on (HIGH is the voltage level)delay(100); // wait for a seconddigitalWrite(PC13, LOW); // turn the LED off by making the voltage LOWdelay(100); // wait for a secondSerial1.println("hello world");}#include <HardwareSerial.h>HardwareSerial Serial1(PA10,PA9);typedef unsigned int time_count;typedef unsigned int State;void setup() {// put your setup code here, to run once:Serial1.begin(115200);pinMode(PA2,OUTPUT);pinMode(PB6,OUTPUT);Serial1.println("hello");}time_count tc0 = 0;time_count tc1 = 0;time_count tc2 = 0;State state2 = 0;bool bl1 = 0;int data = 0;void loop() {// put your main code here, to run repeatedly:tc0 = tc0 +1;delay(1);//fly delay(20)if(tc0 % 20 == 0){tc1 = tc1+1;}if(tc1 > 50 ){bl1 = !bl1;digitalWrite(PA2,bl1);digitalWrite(PB6,!bl1);tc1 = 0;}//breath 0->10 -> 0 silm 50 delay(100);if( tc0 % 100 == 0) //wait delay 50{tc2 = tc2 +1;if(tc2 <= 10){state2 = 0;data = data +1;}else if(tc2 < 20 ){state2 = 1;data = data -1;}else if(tc2 < 70 ){state2 = 3;data = 0;}else{state2 = 0;tc2 = 0;}Serial1.println(data);analogWrite(PA3,data);}}