当前位置:网站首页>Summary of common register bit operation modes in MCU
Summary of common register bit operation modes in MCU
2022-06-24 00:03:00 【Passing bear~】
brief introduction
Register operations are mainly read operations and write operations .
Register write operation
Multiple register bit operations
//GPIO (LED)
#define GPIO_CON (*(volatile unsigned int*)(0xE0200280))
GPIO_CON &= 0XFFFFF8FF; // Need modification D8~D10 position , Make sure D8~D10 Position as 0, Other bits remain the same ( Only for 0 To ensure that the value of this bit can be modified correctly )
GPIO_CON |= 0X00000100; // change D8~D10 state D8~D10 Written as 001 Configure to GPIO function
Single register bit operation
#define GPIO_CON (*(volatile unsigned int*)(0xE0200280))
GPIO_CON &= ~(1<<7); //D7 Location 1 Take the opposite , Equivalent to setting 0( The purpose of this is to ensure that other bits are not affected , Change only the bits that need to be changed )
GPIO_CON |= (1<<7); // Will be the first 7 Bit is set to 1
Register read operation
#define GPIO_CON (*(volatile unsigned int*)(0xE0200280))
GPIO_CON = 0xaa;
printf("reginst====%d======\n", GPIO_CON);
// Take... Respectively 8、7、6、5bit position
int a1 = (GPIO_CON & 0x80) >> 7;
int b1 = (GPIO_CON & 0x40) >> 6;
int c1 = (GPIO_CON & 0x20) >> 5;
int d1 = (GPIO_CON & 0x10) >> 4;
int e1 = (GPIO_CON & 0x08) >> 3;
int f1 = (GPIO_CON & 0x04) >> 2;
int g1 = (GPIO_CON & 0x02) >> 1;
int h1 = (GPIO_CON & 0x01) >> 1;
// obtain 1-4bit position
int i1 = (GPIO_CON & 0x0f);
printf("bit8====%d======\n", a1);
printf("bit7====%d======\n", b1);
printf("bit6====%d======\n", c1);
printf("bit5====%d======\n", d1);
printf("bit4====%d======\n", e1);
printf("bit3====%d======\n", f1);
printf("bit2====%d======\n", g1);
printf("bit1====%d======\n", h1);
printf("bit1-4bit====%d======\n", i1);
边栏推荐
- Docker deploy redis
- Startup process analysis of APP performance optimization
- [technical grass planting] use the shared image function to realize the offline switching from CVM to LH
- 微信小程序 图片验证码展示
- Six complete open source projects, learning enough at a time
- Interpreting the "four thoughts" of Wal Mart China President on the transformation and upgrading of physical retail
- Notepad++实用功能分享(正则行尾行首替换常用方法、文本比对功能等)
- EasyCVR程序以服务启动异常,进程启动却正常,是什么原因?
- 元宇宙中的社会秩序
- Confused test / development programmers, different people have different stories and different puzzles
猜你喜欢

Save: software analysis, verification and test platform

Cloud native architecture (05) - Application Architecture Evolution

AI技术在医学领域有什么用?

Chaos engineering, learn about it

依赖倒置原则

逆向工具IDA、GDB使用

Docker Deployment redis

How to take the PMP Exam agile on June 25? Share your troubles

测试 - 用例篇 - 细节狂魔
![[interview experience package] summary of experience of being hanged during interview (I)](/img/ab/ccee8e624248840e712c0b4ca417dd.png)
[interview experience package] summary of experience of being hanged during interview (I)
随机推荐
Docker redis cluster configuration
Synthetic big watermelon games wechat applet source code / wechat game applet source code
Windows10 security mode entry cycle blue screen repair
Chaos engineering, learn about it
Chrome plug-in features and case analysis of actual combat scenarios
Cross domain issues of the new version of Google browser
Detailed explanation of index invalidation caused by MySQL
Some common tool functions in work
WPF效果之Expander+ListBox
Batch renaming of images by MATLAB
数据库中索引原理及填充因子
Flux in three dimensional vector field
DO280OpenShift访问控制--管理项目和账户
What is the difference between concurrency and parallelism?
First week of summer vacation
[interview experience package] summary of experience of being hanged during interview (I)
云原生架构(05)-应用架构演进
[technical grass planting] the tail of the "double 11" event. Let's talk about how much discount the message push service package is!
Don't miss | Huawei's internal data - Successful Project Management PPT (page 123)
组合总数II[每个元素只能用一次 + 去重复解集]