当前位置:网站首页>STM32 learning record: LED light flashes (register version)
STM32 learning record: LED light flashes (register version)
2022-07-06 15:41:00 【Bitter tea seeds】
List of articles
STM32F103ZE: Punctual atomic elite board , Use register to light up LED
List of articles
- List of articles
- Preface
- One 、 Refer to the development manual
- 1. Open the schematic diagram of punctual atomic elite board , seek LED The pin of
- 2. open STM32 Chinese Reference Manual , Conduct data inquiry
- 3. Then take a look at RCC Register peripheral APB2 Clock enable register
- 4. View register image , Looking for an address
- 5. Check the port output data register
- 6. Check the port configuration low register
- Two 、 Development steps
Preface
The main thing is to be able to use STM3210X The development manual for , Will check the schematic diagram of the board , Understand the concept of bus , Can find registers .
Simply calling the library is not enough , Because it's all encapsulated by others , Want to be an excellent engineer , Must be able to program at the bottom .
One 、 Refer to the development manual
1. Open the schematic diagram of punctual atomic elite board , seek LED The pin of

You can see ,LED0 and LED1 Respectively in GPIOB5 and GPIOE5 On the pin .
2. open STM32 Chinese Reference Manual , Conduct data inquiry
Have a look first STM32 The system structure of 
You can find RCC To control the clock , And GPIOB and GPIOE All by APB2 control
3. Then take a look at RCC Register peripheral APB2 Clock enable register
to glance at APB2 Address offset of 
Check it out. GPIOB and GPIOE Bit 
You can see ,GPIOB It's No 3 position ,GPIOE It's No 6 position ;
4. View register image , Looking for an address

5. Check the port output data register

6. Check the port configuration low register

All right. ! That's all for checking the information , It's not hard , Just know how to find registers .
Two 、 Development steps
1. Lighten up LED
The code is as follows ( Shown ):
RCC Clock address 
#include "stm32f10x.h"
int main(void)
{
*(unsigned int *)0x40021018 |=(1<<3);//RCC The address is 0x40021000,APB2 The offset is 18, therefore , open GPIOB Enable clock . towards ←3 position .
*(unsigned int *)0X40010C00 |=((1)<<(4*5));//‘|=’ Set up 1; Configure low level ,*5 Because in 5 On port
*(unsigned int *)0X40010C0C &=~(1<<5);//‘&=~’ Zero clearing ; Configure port data output
*(unsigned int *)0x40021018 |=(1<<6);// open GPIOE Enable clock . towards ←6 position .
*(unsigned int *)0x40011800 |=((1)<<(4*5));
*(unsigned int *)0x4001180C &=~(1<<5);
}
Verified , Success will punctual the atomic elite board LED0、LED1 The light is on
2. Give Way LED Light flashing
LED.h
The code is as follows ( Shown ):
#ifndef __led_H
#define __led_H
void LED_Init(void);
#endif
LED.c
The code is as follows ( Shown ):
#include "stm32f10x.h"
#include "led.h"
void LED_Init(void)
{
RCC->APB2ENR|=1<<3;//-> Structure pointer ; Can make B
RCC->APB2ENR|=1<<6;//-> Structure pointer ; Can make E
/*GPIOB5*/
GPIOB->CRL&=0xFF0FFFFF;
GPIOB->CRL|=0x00300000;
GPIOB->ODR|=1<<5;
/*GPIOE5*/
GPIOE->CRL&=0xFF0FFFFF;
GPIOE->CRL|=0x00300000;
GPIOE->ODR|=1<<5;
}
main.c
The code is as follows ( Shown ):
#include "stm32f10x.h"
#include "led.h"
#include "delay.h"
int main(void)
{
delay_init(72);
LED_Init();
while(1)
{
GPIOB->ODR|=1<<5;
delay_ms(500);
GPIOB->ODR=~(1<<5);
delay_ms(500);
GPIOE->ODR|=1<<5;
delay_ms(500);
// GPIOB->ODR=~(1<<5);
GPIOE->ODR=~(1<<5);
delay_ms(500);
}
}
边栏推荐
- Do you know the performance testing terms to be asked in the software testing interview?
- Research Report on market supply and demand and strategy of China's Medical Automation Industry
- Cost accounting [22]
- Research Report on printed circuit board (PCB) connector industry - market status analysis and development prospect forecast
- STM32学习记录:LED灯闪烁(寄存器版)
- C语言是低级和高级的分水岭
- UCORE LaB6 scheduler experiment report
- 力扣刷题记录--完全背包问题(一)
- Research Report on medical anesthesia machine industry - market status analysis and development prospect prediction
- Cost accounting [17]
猜你喜欢

洛谷P1102 A-B数对(二分,map,双指针)

STM32學習記錄:輸入捕獲應用

FSM and I2C experiment report

TCP的三次握手与四次挥手

C4D quick start tutorial - Introduction to software interface

学习记录:理解 SysTick系统定时器,编写延时函数

Matlab example: two expressions of step function

Learning record: use STM32 external input interrupt

ucore lab5

JS --- detailed explanation of JS facing objects (VI)
随机推荐
ucore lab5
ucore lab7
Cost accounting [23]
STM32如何使用STLINK下载程序:点亮LED跑马灯(库版本)
STM32 learning record: input capture application
通俗地理解什么是编程语言
Learning record: USART serial communication
How to build a nail robot that can automatically reply
Research Report on market supply and demand and strategy of China's land incineration plant industry
Research Report on market supply and demand and strategy of geosynthetics industry in China
Research Report on market supply and demand and strategy of Chinese graphic screen printing equipment industry
数据在内存中的存储&载入内存,让程序运行起来
Printing quality inspection and verification system Industry Research Report - market status analysis and development prospect forecast
LeetCode#204. Count prime
ucorelab3
编程到底难在哪里?
UCORE lab5 user process management experiment report
ucorelab3
VS2019初步使用
Cost accounting [14]