当前位置:网站首页>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
边栏推荐
- China's salt water membrane market trend report, technological innovation and market forecast
- Introduction to safety testing
- Crawler series (9): item+pipeline data storage
- Cost accounting [15]
- 0-1 knapsack problem (I)
- 用C语言写网页游戏
- How to become a good software tester? A secret that most people don't know
- Intensive learning notes: Sutton book Chapter III exercise explanation (ex17~ex29)
- 基于485总线的评分系统
- The most detailed postman interface test tutorial in the whole network. An article meets your needs
猜你喜欢

Interface test interview questions and reference answers, easy to grasp the interviewer

Optimization method of path problem before dynamic planning

csapp shell lab
Do you know the performance testing terms to be asked in the software testing interview?

TCP的三次握手与四次挥手

csapp shell lab

Learning record: STM32F103 clock system overview working principle
Automated testing problems you must understand, boutique summary

ucorelab3

动态规划前路径问题优化方式
随机推荐
Printing quality inspection and verification system Industry Research Report - market status analysis and development prospect forecast
LeetCode#19. Delete the penultimate node of the linked list
ucorelab4
LeetCode#2062. Count vowel substrings in strings
LeetCode#118. Yanghui triangle
LeetCode#36. Effective Sudoku
Record of force deduction and question brushing
C语言是低级和高级的分水岭
入门C语言基础问答
Cost accounting [16]
力扣刷题记录--完全背包问题(一)
Cost accounting [17]
学习记录:使用STM32F1看门狗
C语言学习笔记
0-1背包问题(一)
Es6---es6 content details
Cost accounting [19]
Cost accounting [15]
Cost accounting [13]
What if software testing is too busy to study?