当前位置:网站首页>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
边栏推荐
- Market trend report, technical innovation and market forecast of lip care products in China and Indonesia
- Winter vacation daily question - maximum number of balloons
- 用C语言写网页游戏
- STM32学习记录:输入捕获应用
- Automated testing problems you must understand, boutique summary
- JS --- detailed explanation of JS facing objects (VI)
- csapp shell lab
- Printing quality inspection and verification system Industry Research Report - market status analysis and development prospect forecast
- Research Report on market supply and demand and strategy of Chinese graphic screen printing equipment industry
- STM32学习记录:LED灯闪烁(寄存器版)
猜你喜欢

CSAPP shell lab experiment report

Leetcode notes - dynamic planning -day6

Take you to use wxpy to create your own chat robot (plus wechat interface basic data visualization)

Learning record: use stm32f1 watchdog
![Unpleasant error typeerror: cannot perform 'ROR_‘ with a dtyped [float64] array and scalar of type [bool]](/img/dc/834463f460c085207dc9d531805e90.jpg)
Unpleasant error typeerror: cannot perform 'ROR_‘ with a dtyped [float64] array and scalar of type [bool]

入门C语言基础问答

How to build a nail robot that can automatically reply

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

Learning record: how to perform PWM output

ucorelab3
随机推荐
csapp shell lab
ucore lab7
数据在内存中的存储&载入内存,让程序运行起来
用C语言写网页游戏
China chart recorder market trend report, technology dynamic innovation and market forecast
VS2019初步使用
ucore lab5
Want to change jobs? Do you know the seven skills you need to master in the interview software test
Cost accounting [16]
How to build a nail robot that can automatically reply
Cost accounting [13]
Record of force deduction and question brushing
Research Report of pharmaceutical solvent industry - market status analysis and development prospect prediction
Learning record: STM32F103 clock system overview working principle
UCORE LaB6 scheduler experiment report
China's earthwork equipment market trend report, technical dynamic innovation and market forecast
China medical check valve market trend report, technical dynamic innovation and market forecast
学习记录:如何进行PWM 输出
毕业才知道IT专业大学生毕业前必做的1010件事
Interface test interview questions and reference answers, easy to grasp the interviewer