当前位置:网站首页>STM32 register on LED
STM32 register on LED
2022-06-30 07:28:00 【weixin_ forty-six million one thousand two hundred and twenty-o】
stm32f10x.h
/* Peripheral base address */
#define PERIPH_BASE ((unsigned int)0x40000000)
/* Bus base address */
#define APB1PERIPH_BASE PERIPH_BASE
#define APB2PERIPH_BASE (PERIPH_BASE + 0x10000)
///* GPIO Peripheral base address */
//#define GPIOA_BASE (APB2PERIPH_BASE + 0x0800)
#define GPIOB_BASE (APB2PERIPH_BASE + 0x0C00)
//#define GPIOC_BASE (APB2PERIPH_BASE + 0x1000)
//#define GPIOD_BASE (APB2PERIPH_BASE + 0x1400)
//#define GPIOE_BASE (APB2PERIPH_BASE + 0x1800)
//#define GPIOF_BASE (APB2PERIPH_BASE + 0x1C00)
//#define GPIOG_BASE (APB2PERIPH_BASE + 0x2000)
/* Register base address , With GPIOB For example */
#define GPIOB_CRL *(unsigned int*)(GPIOB_BASE+0x00)
#define GPIOB_CRH *(unsigned int*)(GPIOB_BASE+0x04)
#define GPIOB_IDR *(unsigned int*)(GPIOB_BASE+0x08)
#define GPIOB_ODR *(unsigned int*)(GPIOB_BASE+0x0C)
#define GPIOB_BSRR *(unsigned int*)(GPIOB_BASE+0x10)
#define GPIOB_BRR *(unsigned int*)(GPIOB_BASE+0x14)
#define GPIOB_LCKR *(unsigned int*)(GPIOB_BASE+0x18)
#define AHBPERIPH_BASE (PERIPH_BASE + 0X20000)
#define RCC_BASE (AHBPERIPH_BASE + 0x1000)
#define RCC_APB2ENR *(unsigned int*)(RCC_BASE+0X18)
mai.c
#include "stm32f10x.h"
void SystemInit()
{
}
int main(void)
{
RCC_APB2ENR|=1<<3; // Turn on RCC_APB2gpioB The clock
//CRL Low control 8 Bit pin output mode
GPIOB_CRL &= ~( 0x0F<< (4*5));//(4*5) Set the pin position to be controlled as 0000 Universal push-pull output mode
GPIOB_CRL |= (3<<4*5); // Set up 3=11 Output maximum speed 50MHZ 4*5 Indicates which bit to control
//GPIOB_CRL Is the control low octet pin ,GPIOB_CRH Is the control high octet pin
// GPIOB_BSRR=(1<<(16+5)); // Control which pin , low 16 position =1 Is a high level , high 16 position =1 Is a low level
GPIOB_ODR&=~(1<<5); // also ODR Which pin is directly set 1 perhaps 0,1 High level ,0 Low level
//GPIOB_ODR|=(1<<5);
/* among
GPIOB_ODR The initial value is 0x0000 0000
GPIOB_ODR &= ~(1<<5); three
1. Move left 1 << 4 = 0001 0000
2. Take the opposite ~(1 << 5)= 1110 1111
3. Bitwise AND , if GPIOB_ODR The initial value is 0x1111 1111
1111 1111
1110 1111
——————————————
1110 1111
Thus, other bits are reserved
GPIOB_ODR |= (1<<5);
1. Move left 1 << 5 = 0001 0000
2. Press bit or , if GPIOB_ODR The initial value is 0x0000 0000
0000 0000
0001 0000
——————————————
0001 0000
Thus, other bits are reserved
*/
}
边栏推荐
- Keil serial port redirection
- Halcon: read the camera and binary it
- Quick placement of devices by module in Ad
- Ad usage notes
- Proteus catalog component names and Chinese English cross reference table
- How to batch modify packaging for DXP schematic diagram
- Private method of single test calling object
- DXP software uses shortcut keys
- 1285_ Expand macros defined by AUTOSAR functions and variables with scripts to improve readability
- Assembly learning register
猜你喜欢

Network security - routing principle

Use of ecostruxure (3) creating composite function blocks

C language implementation sequence stack

oracle数据库报列表中最大表达式为1000错误

Minecraft 1.16.5模组开发(五十) 书籍词典 (Guide Book)

Realization of dissolve effect in unity and its principle analysis

Install go language development tools

Calculation and parameter quantity of neural network

Adjacency matrix representation of weighted undirected graph (implemented in C language)

nRF52832 GPIO LED
随机推荐
Golan common shortcut key settings
Quick placement of devices by module in Ad
Mailbox application routine of running wild fire RT thread
嵌入式测试流程
Pool de Threads - langage C
SQL Server2005中SUM函数内嵌套IF语句
Stm32g0 porting FreeRTOS
【已解决】ERROR 1290 (HY000): Unknown error 1290
QT elementary notes
Socket socket programming -- UDP
Realization of dissolve effect in unity and its principle analysis
[solved] failed! Error: Unknown error 1130
网络安全-三层交换技术和内部网络规划
How to batch modify packaging for DXP schematic diagram
Keil plug-in Usage Summary
[implemented] server jar package startup script and shell script
记录开发过程中无法使用管理员身份修改系统文件问题
C language implementation sequence stack
Resolved: initialize specified but the data directory has files in it Aborting
LabVIEW程序代码更新缓慢