当前位置:网站首页>Application of pointer in STC89C52 single chip microcomputer and demonstration of practical cases
Application of pointer in STC89C52 single chip microcomputer and demonstration of practical cases
2022-06-30 01:06:00 【A piglet who likes fried chicken】
Catalog
C In language * The function of
Directly access the data under the physical address
Access the data in the memory specified by the hardware , Such as equipment ID Number, etc.
Convert complex format data into bytes , Convenient communication and storage
The pointer (Pointer) yes C An important knowledge point of language , Its use is flexible 、 Powerful , yes C The soul of language
Pointers are closely related to the underlying hardware , Use a pointer to manipulate the address of the data , Realize indirect access to data

Small end allocation mode :
Store the number from small to large in the address from small to large , This storage method is called small end allocation
Different variables in the array are also stored in the order of address from small to large , No other data is stored in the middle .
The same if short c[ ] This type , Then each data is internally divided into short The way to store , Instant 2 Byte store , Different data are stored in sequence

C In language * The function of :
1, Multiplication sign
2, Define pointer
3, Take out the data

Data width :
The pointer takes a data as the basic unit when adding and subtracting , Otherwise, it's meaningless .
If the definition is int Pointer to type , Then adding and subtracting is equivalent to adding and subtracting 4 Bytes .


C Use language skillfully & And * Transform the data , Ensure that the pointer level is consistent , If necessary, you may need to use a cast :
float num;
unsigned char *p;
p=(unsigned char *)#The following is about C Common pointer uses in languages :
Pass parameters
Use a pointer to pass a large number of parameters ( Array ), The main function and the sub function use the same set of data , Avoid data duplication during parameter transfer , Improved operational efficiency , Reduced memory usage
Use pointers to pass output parameters , Using the same set of data for main function and sub function , Realize the return of data , Can realize the design of multi return value function
( Formal parameter and actual parameter , Ensure the data stability of sub function and main function , The parameter of the number of subculverts is set to pointer , Data replication is avoided, but the number of subculverts can change the data , Except with const modification .)
Array storage is an equivalent method implemented with pointers :

Const Modification to avoid unauthorized modification of the data passed by the main function

Use pointers to pass , Realize the design of multi return value function

C Language library functions such as strcpy( ), Move the mouse over the brackets , You can find that the definition is also a pointer 
Pass the return value
Return the public part in the module to , Let the main function hold the “ Handle ”, It is convenient for the program to operate on the specified object
( The public part here is simply a global variable , Note that it cannot be a local variable , Because at the end of the call , Local variables will be destroyed )
For example, it is used here GetTime Function to make the main function modifiable Time The data in the array :
C The language file function creates a file for the specified location , And store the data
C The language file function reads the file to the specified location , And display data
Directly access the data under the physical address
Access the data in the memory specified by the hardware , Such as equipment ID Number, etc.

RAM Single chip computer at ID distinguish :

Single chip microcomputer in program area ID distinguish : ( Prefix with code Means defined in ROM The address in )

Convert complex format data into bytes , Convenient communication and storage
( For example, floating point data is transferred when different devices communicate )
It is not convenient to show the data exchange between different devices , So use different modules in the program to simulate , among AirData It's data sent over the air
General principles : Convert floating point numbers to char type , Send out byte by byte . Then accept that it will char Turn into float Type to decode , Printout .
Air data module

Send data module

Accept data modules

边栏推荐
- 利用tsne将不同句子关于相似度可视化出来
- Newton method (optimization of two variable functions)
- How did the data center change from "Britney Spears" to "Mrs. bull"?
- How to switch to root in xshell
- 浅析现代Web端im即时通讯开发技术
- 岁月匆匆那年
- xshell中怎么切换到root用户
- Seata 與三大平臺攜手編程之夏,百萬獎金等你來拿
- The listing of Symantec electronic sprint technology innovation board: it plans to raise 623million yuan, with a total of 64 patent applications
- 利用huggingface进行文本分类
猜你喜欢

Analysis of IM instant messaging development technology on modern web

Go 中的 UDP 服务器和客户端

How to create a module in the idea and how to delete a module in the idea?
![[lorawan node application] the application and power consumption of Anxin ra-08/ra-08h module in lorawan network](/img/5d/9cff7bd25841c1ca6e5ab8e2994f51.png)
[lorawan node application] the application and power consumption of Anxin ra-08/ra-08h module in lorawan network

我,33岁,字节跳动测试开发,揭开北京“测试岗”的真实收入

利用tsne将不同句子关于相似度可视化出来

网易云音乐内测音乐社交 App“MUS”,通过音乐匹配同频朋友

外包干了三年,废的一踏糊涂...

2022 6 月25 日交易总结

Developers, why does the maturity of container technology herald the arrival of cloud native era?
随机推荐
如何在IDEA中创建Module、以及怎样在IDEA中删除Module?
VIM editor common instructions
How to refuse the useless final review? Ape tutoring: it is important to find a suitable review method
Seata and the three platforms are working together in the summer of programming. Millions of bonuses are waiting for you
Outsourcing for 3 years is a waste
How to switch to root in xshell
练习副“产品”:自制七彩提示字符串展示工具(for循环、if条件判断)
出门在外保护好自己
Solution to webkitformboundaryk in post request
numpy的索引和图片的索引一样吗?
一些生活的思考
解决choice金融终端Excel/Wps插件修复visual basic异常
What if you can't write your composition well? Ape counseling: parents should pay attention to these points
[Simulation Proteus] détection de port 8 bits 8 touches indépendantes
Cantilever beam calculation [matlab code]
阿洛觉得自己迷茫
【three.js】WEB3D初次体验
DL: deep learning model optimization model training skills summary timely automatic adjustment of learning rate implementation code
传统微服务框架如何无缝过渡到服务网格 ASM
利用huggingface进行文本分类


