当前位置:网站首页>Lpc1768 optimization comparison of delay time and different levels
Lpc1768 optimization comparison of delay time and different levels
2022-04-23 19:29:00 【ToneChip】
Because I'm writing IIC When , A software is used to simulate IIC To drive the encryption chip , So you need to write a delay Function to control timing , But when I do a good job without code optimization code Become the highest level ( The fastest , Code optimization ) After the optimization of the , Find out IIC The verification failed , It is initially suspected that the timing of the software is not right , So using IO The time comparison of different delay functions is tested with the logic analyzer .
//=2022.04.21 In order to test delayms The specific time of function delay , Use IO Flip to measure
void TestDelay(void)
{
LEDInitOnCS0804();
// __enable_irq();
while(1)
{
LED_ON;
atca_delay_us2(1);
LED_OFF;
atca_delay_us2(1);
}
}
/************************************************
Optimization grade none low Med High (ms)
delayms(1); 0.29 0.27
delayms(4); 0.59 0.57
delayms(10); 1.19 1.17
delayms(1000); 100.1 100.1 100.1
atca_delay_us2(1); 2.75us 1.5us
atca_delay_us3(1); 5us 4.75us
************************************************/
The typesetting is not quite right , Only the highest level and none
Each function is defined as follows
//#pragma optimize=none
void delayms(int ms)
{
//2019.01.01 Fill the pit here
// When high-level optimization is selected , In the circulation without any action, use volatile To define variables
volatile int i;
volatile int j;
// int i;
// int j;
// for( i = 0; i<16666; i++) // about 1ms
// for( j = 0; j<ms; j++);
for( i = 0; i < 1000; i++) //=1000 OK
for( j = 0; j < ms; j++);
// asm( " nop " );
// asm( " nop " );
// asm( " nop " );
}
void atca_delay_us2(uint32_t nus)
{
int i;
int j;
for( i = 0; i < 17; i++) // about 1us = 16.6666
for( j = 0; j < nus; j++);
}
void atca_delay_us3(uint32_t nus)
{
volatile int i;
volatile int j;
for( i = 0; i < 17; i++) // about 1us = 16.6666
for( j = 0; j < nus; j++);
}
Through comparison, we found that atca_delay_us2 and atca_delay_us3 The only difference is that the variable uses volatile
summary : Use volatile Modified variables have no effect on code optimization in engineering
Finally, with IAR6.3 Code optimization opens the selection interface
版权声明
本文为[ToneChip]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231923488342.html
边栏推荐
- Oracle configuration st_ geometry
- PostgreSQL
- Machine learning catalog
- Speex Wiener filter and rewriting of hypergeometric distribution
- LPC1768 关于延时Delay时间与不同等级的优化对比
- MySQL数据库 - 单表查询(一)
- Codeworks round 783 (Div. 2) d problem solution
- SQL server requires to query the information of all employees with surname 'Wang'
- 【webrtc】Add x264 encoder for CEF/Chromium
- @Analysis of conditional on Web Application
猜你喜欢
Decompile and get the source code of any wechat applet - just read this (latest)
First experience of using fluent canvas
Grafana 分享带可变参数的链接
NiO related Basics
ArcMap connecting ArcGIS Server
Use of fluent custom fonts and pictures
Oracle配置st_geometry
山大网安靶场实验平台项目—个人记录(四)
The most detailed network counting experiment in history (2) -- rip experiment of layer 3 switch
Build intelligent garbage classification applet based on Zero
随机推荐
Openlayers 5.0 loading ArcGIS Server slice service
Regular expressions for judging positive integers
Intuitive understanding of the essence of two-dimensional rotation
Zero base to build profit taking away CPS platform official account
Audio signal processing and coding - 2.5.3 the discrete cosine transform
filebeat、logstash配置安装
HTTP cache - HTTP authoritative guide Chapter VII
What is a message queue
视频理解-Video Understanding
Inject Autowired fields into ordinary beans
考试系统进入试卷优化思路
Kubernetes入门到精通-KtConnect(全称Kubernetes Toolkit Connect)是一款基于Kubernetes环境用于提高本地测试联调效率的小工具。
OpenHarmony开源开发者成长计划,寻找改变世界的开源新生力!
点云数据集常用处理
C学习完结
Class loading mechanism
Scrum Patterns之理解各种团队模式
Virtual machine performance monitoring and fault handling tools
Mfcc: Mel frequency cepstrum coefficient calculation of perceived frequency and actual frequency conversion
arcgis js api dojoConfig配置