Arduion-STM32

 Arduion-STM32

stm32duino 让stm32 在arduino中使用

源代码:GitHub - stm32duino/Arduino_Core_STM32: STM32 core support for Arduino

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 Serial1(PA10,PA9);

void setup() {

  Serial1.begin(115200);

 pinMode(PC13, OUTPUT);

 Serial1.println("hello");

}

// the loop function runs over and over again forever

void loop() {

 Serial2.println("hello world");

 digitalWrite(PC13, HIGH);  // turn the LED on (HIGH is the voltage level)

 delay(100);       // wait for a second

 digitalWrite(PC13, LOW);  // turn the LED off by making the voltage LOW

 delay(100);       // wait for a second

 Serial1.println("hello world");

}

#include

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);

  }

}

stm32 arduino -2023-7-11

关闭杀毒软件或放入白名单,可以解决大部份问题

 记录一下arduino ide 使用stm32的过程

如有冒犯,敬请告之,侵删

网上很多教程,可以用的,并且通过编辑实现了的配置板支持包,使用Arduino IDE对STM32全系列芯片编程_arduino_stm32库_笑春风oO的博客-CSDN博客

感谢博主提供的下载程序

链接:https://pan.baidu.com/s/171KNtN7ltdfYgnKYrO433w 
提取码:r8ky

下载后 joson 放在 c:\users\用户名\appdata\arduino 

其它放在  C:\Users\用启名\AppData\Local\Arduino15\staging\packages下

记得重起

下载程序 

使用 usb转 ttl (ch340)芯片

usb 转ttl  TX->PA10 RX ->PA9 GND->GND 3.3V ->3.3V 

使用boot0 = 1 boot1 = 0;

下载完成后 boot0 = 0 下次启动才可自动,否则不启动下载程序

blink 程序

void setup() {

  pinMode(PC13, OUTPUT);

  Serial.begin(115200);

}

// the loop function runs over and over again forever

void loop() {

  digitalWrite(PC13, HIGH);   // turn the LED on (HIGH is the voltage level)

  delay(1000);              // wait for a second

  digitalWrite(PC13, LOW);    // turn the LED off by making the voltage LOW

  delay(1000);              // wait for a second

  Serial.println("hello world");

}

Arduion-STM32_第1张图片

​编辑

使用网上最近的教程,从github 下载安装包,安装后,无法通过编辑,或出现错误

由于时间久,没人维护,出现错误

出现问题

踏过的坑

包括下载 stm32 cube programmer 

从github 下载安装包,安装

开发板管理 arduino sam boards m3+....

1.github下载安装包置入 packages 后 开发板管理 下载 arduino ---------无效,产生错误

2.网上最新教程,------无效

3 stm32 cube program -无效 ,安装失败

错误1. busybox.exe 找不到  (下载 stm32duino 下有个stm32tool 项目,内含有busybox.exe)

STM32 Project Won't Build Due To Path Issue - #3 by spcplugins - IDE 2.x - Arduino Forum

按照上面的方法,无法解决问题,并且国内无法下载

错误2 .STM32 Project Won't Build Due To Path Issue - #3 by spcplugins - IDE 2.x - Arduino Forum

御载 arduino sam boards (..... corel - m3)

最后如果

学习stm32的话,还是推荐去正点原子 虽然贵点,资料,板子全

你可能感兴趣的:(arduino,单片机,嵌入式硬件)