当前位置:网站首页>A method of quickly transplanting library function code to register code by single chip microcomputer
A method of quickly transplanting library function code to register code by single chip microcomputer
2022-06-26 04:39:00 【Embedded @hxydj】
Now more and more SCM development uses the library function version , Register versions are used less and less . However, using library functions in some projects will cause the program to run slowly , It runs faster without directly operating registers . So in the projects with strict time requirements , You still need to use registers to develop . If you can't find the register related sample code , It is difficult to develop . Today, let's summarize a method for quickly porting library functions to registers , This method is a general method , It can be used on any single chip microcomputer .
Now use one STM8 SCM library function project to give an example .


The main function of this code is to use the timer 1 To calculate the frequency of the input waveform . For the initialization of timers, library functions are used , Now change the library function of timer initialization part to register .
First, single step debugging , Enter the initialization function .
Step into this function .
You can see that in this function 6 A register , Will this 6 Registers are added to the observation window respectively .
In the code, registers are operated by means of pointers , So you should pay attention to the name format when adding registers to the observation window , Need to put TIM1->ARRH It is amended as follows TIM1_ARRH Format . When adding registers , You can click the mouse directly at the position of the observation window expression , Enter the name of the register directly .
Then change the display mode of register value to 16 Base display . Right click the register in the observation window , choice 16 Base display .
Add all other registers in the same way .
At this time, the values of the registers are all the default values , Then step through the program . Observe the change of register value .
After the current function is executed , All register values are the values set by the library function . Record the values of these registers .
amount to TIM1_TimeBaseInit() The function sets these registers , Then the set register value is the value in the variable observation window . Follow the same method , Sequential single step commissioning , Record the values of all initialization registers .
When all the register values in the initialization code are recorded , In this case, you can directly replace the library function with a register .
Run the program after the replacement , Observe whether the running results of the program are correct . By observing the result of serial port output, it is proved that the program execution is correct .
In this way, through the method of single step debugging , Directly observe the value of the register , You can quickly figure out which registers are set in the library function code , What is the set value . When the set register value is known , And then by looking up the information of single-chip computer , Compare the meaning of each bit in the register , You know which functions to use and which bits of which registers to set .
After reading the register data , Understand the function of each register , At this time, you can optimize the initialization of registers , Make the code look clearer .
Change the setting of the register to bit operation mode , In this way, you can see which bits of which register are operated directly through the code . Recompile and download after modification , Verify whether the modified code functions properly .
Through this method, we can quickly understand the use of registers , Otherwise, just look at the relevant manual of SCM register , No focus , And some manuals are very large , Look at the back and forget the front , Very inefficient . At the same time, I don't know clearly in the process of reading , In which function should some registers be set . And through the method of single step debugging , Directly observe the register set in the library function , You can quickly understand the function of registers , You can see the data of the corresponding register when you use what function , It avoids the waste of time by simply reading materials , It also improves learning efficiency .
边栏推荐
- PHP inherited in class return does not work
- 2022.1.23
- Navicat connects the pit of shardingsphere sub table and sub library plug-ins
- [H5 development] 03- take you hand in hand to improve H5 development - single submission vs batch submission with a common interface
- PHP installation SSH2 extension
- Thinkphp6 parsing QR code
- Notes on enterprise wechat development [original]
- PHP has the problem of using strtotime to obtain time in months and months [original]
- Jenkins introduces custom jars
- Nabicat connection: local MySQL & cloud service MySQL and error reporting
猜你喜欢

Minecraft 1.16.5 生化8 模组 1.9版本 1.18版本同步

Yapi cross domain request plug-in installation

1.19 learning summary

The statistics in the MySQL field become strings, and then they are converted into numbers for sorting

NVM installation and use and NPM package installation failure record

1.18 learning summary

Tp6 multi table Association (table a is associated with table B, table B is associated with table C, and table d)

Text horizontal alignment attribute text align and element vertical alignment attribute vertical align

MySQL enable logbin in Qunhui docker
![[H5 development] 02 take you to develop H5 list page ~ including query, reset and submission functions](/img/39/64df931d5ec54d7d19ae444fa372ba.jpg)
[H5 development] 02 take you to develop H5 list page ~ including query, reset and submission functions
随机推荐
pip 批量完全卸载包
Ueeditor automatically appends P tags to rich text.br tags always wrap.br tag solutions
Add, delete, modify and query curd in PHP native SQL
基础查询
问题随记 —— pip 换源
NPM installation tutorial
Multipass中文文档-远程使用Multipass
Multipass中文文档-使用实例命令别名
Laravel file stream download file
Sixtool- source code of multi-functional and all in one generation hanging assistant
2021/11/6-burpsuit packet capturing and web page source code modification
CTF serialization and deserialization
1.11 learning summary
Laravel pay payment access process
Realize video call and interactive live broadcast in the applet
Composer version rollback version switching
6、 Project practice --- identifying cats and dogs
1.18 learning summary
Motivational skills for achieving goals
Video label forbids downloading. The test is valid. Hide button. The test is valid at three points