当前位置:网站首页>Stm32f10x -- C Language-1
Stm32f10x -- C Language-1
2022-07-27 11:29:00 【YovaVan】
review 51 Single chip microcomputer :
Register mapping : The memory corresponding to each peripheral has an address , By keyword ( for example sfr) Implement register mapping , Name the address .
MCU has port (51 Yes 4 individual ), The corresponding address 0x80,0x90,0xA0,0xB0, adopt
sfr P0 = 0x80;
sfr P1 = 0x90;
sfr P2 = 0xA0;
sfr P3 = 0xB0;Implement register definition . Use directly when programming P0 Assign a value , Such as :
P0 = 0xFE; /*51 Only 8 bits,0b11111110*/STM32F103:
Let someone GPIO Port of 16 Pin implementation high / Low level output ( meanwhile ):
( port ) Output data register ODR(output data register), low 16 Bit effective ,16 All pins output low level, so it is necessary to turn low 16 The bits are set to 1 that will do .
The connection indicator of your board is GPIOE, stay “ Bus architecture ” Port found E Address range : 0x40011800-0x40010FFE.
Address offset : The offset of the register from the bus base address , Here is 0x4001180C.
(unsigned int *) The role of : Cast
GPIOE_ODR The address is 0x4001180C, The compiler does not consider it an address , So we need to use
(unsigned int *)0x4001180C;Yes 0x4001180C Cast .
“*” The role of : Pointer the address . namely :
*(unsigned int*)0x4001180C; The above is the most basic and cumbersome implementation , You can optimize with macro definitions . The box #define Address (unsigned int *)0x4001180C Defined as a macro , sentence :
#define GPIOE_ODR (unsigned int*)0x4001180C; Then operate the macro with pointer and assign value , sentence :
* GPIOE_ODR = 0xFF;You can put the previous sentence * Move the number to the macro definition statement , namely :
#define GPIOE_ODR *(unsigned int*)0x4001180C; Direct assignment :
GPIOE_ODR = 0xFF;边栏推荐
- "My" bug collection (Reprinted)
- Moveit2 - 5. Scenario Planning
- Win10 vscode code code format setting and remote breakpoint debugging
- 15 design movie rental system
- 背包模型 AcWing 1022. 宠物小精灵之收服
- 洛谷P1896 互不侵犯
- 博弈论 AcWing 892. 台阶-Nim游戏
- (5) Printf (instead of echo)
- Quantitative industry knowledge summary
- Game theory acwing 891. Nim game
猜你喜欢

Cancer DDD

Introduction to software vulnerability analysis (I)

Game theory acwing 894. Split Nim game

数字三角形模型 AcWing 275. 传纸条

求组合数 AcWing 886. 求组合数 II

区间问题 AcWing 906. 区间分组

Force buckle - 10. Regular expression matching

Find the combination number acwing 886. find the combination number II

高斯消元 AcWing 884. 高斯消元解异或线性方程组

数字三角形模型 AcWing 1027. 方格取数
随机推荐
PAT(乙级)2022年夏季考试
4 search insertion location
A deep analysis of the soul of C language -- pointer
10 complete half of the questions
背包问题 AcWing 9. 分组背包问题
最长上升子序列模型 AcWing 1010. 拦截导弹
Moveit2 -- 2. Quick start of moveit in rviz
Caused by:org.gradle.api.internal. plugins . PluginApplicationException: Failed to apply plugin
博弈论 AcWing 893. 集合-Nim游戏
Longest ascending subsequence model acwing 1014. mountaineering
Tree DP acwing 285. dance without boss
Ansible
Longest ascending subsequence model acwing 1010. Interceptor missile
C# 自定义集合
Game theory acwing 892. Step Nim game
最长上升子序列模型 AcWing 1016. 最大上升子序列和
栈 AcWing 3302. 表达式求值
Solutions to errors in tensorflow operation
最长上升子序列模型 AcWing 1017. 怪盗基德的滑翔翼
Longest ascending subsequence model acwing 272. longest common ascending subsequence