当前位置:网站首页>STM32 how to use stlink download program: light LED running light (Library version)
STM32 how to use stlink download program: light LED running light (Library version)
2022-07-06 15:41:00 【Bitter tea seeds】
List of articles
STM32F103ZE Learning record : Main reference The punctual atoms course
List of articles
Preface
This note mainly introduces the use ST_SLINK Burn and light up LED Lamp program , And some problems I encountered ,
One 、 Construction of environment
1. Operating steps for creating a new programming file
1.1 In the built project documents , Create a new peripheral folder
1.2 In the project folder , Add a path
1.3 establish <.c> and <.h> file
1.4 take <.c> Add file to folder
<.h> The same procedure
2.ST_LINK Burn build
2.1 Click on the magic wand
But I'm using STLINK There was a problem downloading
3.STlink Download appears st-link usb communication error resolvent
The solution is to Firmware upgrade ;
Click on ST-LinkUpgrade.exe, open st-link upgrade Software firmware upgrade
Plug in st-link Firmware to computer , Click on Device Connect Button , Connect st-link
Never put USB Unplug the connector , Otherwise, the upgrade will fail
If the following error appears , You can try to plug and unplug again st-link The firmware , Or a different one usb Interface
Successful connection ! Here's the picture , You can see the current firmware version and the version to be upgraded , Click on yes upgrade
Update driver
Run as Administrator D:\MDKkeil5\ARM\STLink\USBDriver\stlink_winusb_install.bat file , Update the driver
Click next , Until completion .
The problem is solved easily and happily !
Two 、LED Lantern program
STM32 And 51 SCM is really different ,STM32 than 51 The more advanced ;
STM32 The program directly calls library functions , Than 51 Much more convenient ,STM32 There are many registers in the system , The function is better than 51 To be stronger .
* Operation steps Learn from punctual atoms PPT
In fact, it also operates on registers .
1.LED.c Program
Important functions used * Learn from punctual atoms PPT
The code is as follows ( Shown ):
#include "led.h"
#include "stm32f10x.h"
void LED_Init(void)
{
GPIO_InitTypeDef GPIO_InitStruct;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB,ENABLE);// Can make GPIOB The clock of
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOE,ENABLE);// Can make GPIOE The clock of
GPIO_InitStruct.GPIO_Mode=GPIO_Mode_Out_PP;// Push pull is selected because it can directly output high level
GPIO_InitStruct.GPIO_Pin=GPIO_Pin_5;// choice GPIOB5
GPIO_InitStruct.GPIO_Speed=GPIO_Speed_50MHz;// The output speed is 50M
GPIO_Init(GPIOB,&GPIO_InitStruct);//GPIOB5 initialization
GPIO_SetBits(GPIOB,GPIO_Pin_5);// Yes GPIOB5 Set high level
GPIO_InitStruct.GPIO_Mode=GPIO_Mode_Out_PP;// Push pull is selected because it can directly output high level
GPIO_InitStruct.GPIO_Pin=GPIO_Pin_5;// choice GPIOB5
GPIO_InitStruct.GPIO_Speed=GPIO_Speed_50MHz;// The output speed is 50M
GPIO_Init(GPIOE,&GPIO_InitStruct);//GPIOE5 initialization
GPIO_SetBits(GPIOE,GPIO_Pin_5);// Yes GPIOE5 Set high level
}
2.LED.h Program
The code is as follows ( Shown ):
#ifndef __led_H
#define __led_H
void LED_Init(void);
#endif
Here I came across a warning , It's very interesting
3…\harwred\led\led.h(7): warning: #1-d: last line of file ends without a newline
This may be MDK A small colored egg left by the developer , Is the last line of code , You must return the train , I feel that person must have OCD .
4.main.c Program
Just call the function
The code is as follows ( Shown ):
#include "stm32f10x.h"
#include "led.h"
#include "delay.h"
int main(void)
{
LED_Init();// Conduct LED Initialized call
delay_init();// Call to initialize the delay function
while(1)
{
GPIO_SetBits(GPIOB,GPIO_Pin_5);// Yes GPIOB5 Set high level
delay_ms(500);// Time delay 500 millisecond
GPIO_ResetBits(GPIOB,GPIO_Pin_5);// Yes GPIOB5 Set low level
delay_ms(500);// Time delay 500 millisecond
GPIO_SetBits(GPIOE,GPIO_Pin_5);// Yes GPIOE5 Set high level
delay_ms(500);// Time delay 500 millisecond
// GPIO_ResetBits(GPIOB,GPIO_Pin_5);// Yes GPIOB5 Set low level
GPIO_ResetBits(GPIOE,GPIO_Pin_5);// Yes GPIOE5 Set low level
delay_ms(500);// Time delay 500 millisecond
}
}
5. The last part STLINK The download
Experimental phenomena
STM32LED Light flashing
边栏推荐
- Cost accounting [13]
- ArrayList集合
- 编程到底难在哪里?
- 51 lines of code, self-made TX to MySQL software!
- Cost accounting [23]
- Crawler series of learning while tapping (3): URL de duplication strategy and Implementation
- Market trend report, technological innovation and market forecast of pneumonia drugs obtained by Chinese hospitals
- ucorelab4
- 0-1背包問題(一)
- 程序员的你,有哪些炫技的代码写法?
猜你喜欢
Automated testing problems you must understand, boutique summary
What is "test paper test" in software testing requirements analysis
毕业才知道IT专业大学生毕业前必做的1010件事
用C语言写网页游戏
Lab 8 file system
JS --- detailed explanation of JS facing objects (VI)
CSAPP shell lab experiment report
学习记录:使用STM32外部输入中断
差分(一维,二维,三维) 蓝桥杯三体攻击
The most detailed postman interface test tutorial in the whole network. An article meets your needs
随机推荐
Cost accounting [13]
TCP的三次握手与四次挥手
Medical colposcope Industry Research Report - market status analysis and development prospect forecast
Crawling cat's eye movie review, data visualization analysis source code operation instructions
Crawler series of learning while tapping (3): URL de duplication strategy and Implementation
STM32学习记录:输入捕获应用
Accounting regulations and professional ethics [1]
Indonesian medical sensor Industry Research Report - market status analysis and development prospect forecast
Cost accounting [17]
Cost accounting [24]
Research Report on market supply and demand and strategy of China's Medical Automation Industry
Scoring system based on 485 bus
China medical check valve market trend report, technical dynamic innovation and market forecast
Research Report on market supply and demand and strategy of Chinese graphic screen printing equipment industry
学习记录:理解 SysTick系统定时器,编写延时函数
Accounting regulations and professional ethics [2]
基于485总线的评分系统
ucorelab3
学习记录:串口通信和遇到的错误解决方法
What is "test paper test" in software testing requirements analysis