当前位置:网站首页>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
边栏推荐
- Openlayers 5.0 reload the map when the map container size changes
- 考试系统进入试卷优化思路
- Encyclopedia of professional terms and abbreviations in communication engineering
- Solve the problem of invalid listview Click
- OpenHarmony开源开发者成长计划,寻找改变世界的开源新生力!
- HTTP cache - HTTP authoritative guide Chapter VII
- JS controls the file type and size when uploading files
- uIP1.0 主动发送的问题理解
- RuntimeError: Providing a bool or integral fill value without setting the optional `dtype` or `out`
- [report] Microsoft: application of deep learning methods in speech enhancement
猜你喜欢
![[report] Microsoft: application of deep learning methods in speech enhancement](/img/29/2d2addd826359fdb0920e06ebedd29.png)
[report] Microsoft: application of deep learning methods in speech enhancement

Zero cost, zero foundation, build profitable film and television applet

Kubernetes入门到精通-KtConnect(全称Kubernetes Toolkit Connect)是一款基于Kubernetes环境用于提高本地测试联调效率的小工具。

Decompile and get the source code of any wechat applet - just read this (latest)

An algorithm problem was encountered during the interview_ Find the mirrored word pairs in the dictionary

2021-2022-2 ACM training team weekly Programming Competition (8) problem solution

The platinum library cannot search the debug process records of some projection devices

Zero base to build profit taking away CPS platform official account

MySQL syntax collation

Lottery applet, mother no longer have to worry about who does the dishes (assign tasks), so easy
随机推荐
MySQL syntax collation
Is meituan, a profit-making company with zero foundation, hungry? Coupon CPS applet (with source code)
Pit encountered using camera x_ When onpause, the camera is not released, resulting in a black screen when it comes back
goroutine
openlayers 5.0 当地图容器大小改变时,重新加载地图
深度学习环境搭建步骤—gpu
深度学习——特征工程小总结
音频编辑生成软件
【webrtc】Add x264 encoder for CEF/Chromium
What is a message queue
Why is the hexadecimal printf output of C language sometimes with 0xff and sometimes not
ArcGIS JS API dojoconfig configuration
RuntimeError: Providing a bool or integral fill value without setting the optional `dtype` or `out`
Lottery applet, mother no longer have to worry about who does the dishes (assign tasks), so easy
C学习完结
NiO related Basics
Grafana 分享带可变参数的链接
MFCC: Mel频率倒谱系数计算感知频率和实际频率转换
[H264] hevc H264 parsing and frame rate setting of the old version of libvlc
@MapperScan与@Mapper