当前位置:网站首页>How to delay the delay function
How to delay the delay function
2022-06-25 18:05:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm your friend, Quan Jun .
How the delay function delays
** Function example Compiled by the compiled software Assembly instruction
Delay_ms(200); // 1、 0x0000058C 20C8 MOVS r0,#0xC8
void Delay_ms(unsigned int time)
{
unsigned char n;
while(time>0) // 3、0x00000210 2800 CMP r0,#0x00
{
for(n=0;n<4;++n) // 4、 0x00000204 2100 MOVS r1,#0x00
{ // 5、 0x00000206 1C49 ADDS r1,r1,#1
; // 6、 0x00000208 B2C9 UXTB r1,r1
// 7、 0x0000020A 2902 CMP r1,#0x02
// 8、 0x0000020C D3FB BCC 0x00000206
// 9、 0x0000020E 1E40 SUBS r0,r0,#1
}
time--; // 2、 0x00000202 E005 B 0x00000210
}
}What you need to know 1、 Each assembly instruction takes several clock cycles , Easy to calculate how much time 2、 The clock period is 1M when , The reciprocal is time 1us
Text interpretation
Program entry Delay_ms(200) After delay function , The running sequence of the corresponding assembly instructions is 1——2——3——4——5——6——7——8——9 Among them for The assembly instructions for an empty loop are 5、6、7、8、9 These four , Get into for The number of times these four instructions are run in a loop is 4( From your own settings n<4) The corresponding assembly instructions in this function generally occupy one clock cycle , Among them the first 2 and 8 There are jump instructions , Occupy 2 Clock cycles , The hardware clock of this function program is set to 22MHz, Therefore, the delay function time is (10+8*(n-1))*(1/22M)us
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/151107.html Link to the original text :https://javaforall.cn
边栏推荐
猜你喜欢

智能对话01-redis的安装

Encryption trend: Fashion advances to the meta universe

QT中QString包含“\u0000“的处理方式

win10安装cuda的操作步骤(不断完美中)

近来开发的一款简单易用的图可视化工具

Deeply understand and grasp the basic characteristics of digital economy

The Stackies 2022:32个营销技术栈入选

什么是算子?

Optimization of lazyagg query rewriting in parsing data warehouse

Garbage collector and memory allocation strategy
随机推荐
A simple and easy-to-use graph visualization tool developed recently
win10安装cuda的操作步骤(不断完美中)
SQL Server real time backup library requirements
QT generate random numbers (random strings) within the specified range
User scheduling problem
Deep understanding of ELF files
ASP. Net supermarket convenience store online shopping mall source code, for the surrounding distribution system
股票开户怎么办理 办理开户安全吗
Introduction to the container of() function
实际开户复杂吗?在线开户安全么?
Unity technical manual - lifecycle rotation rotationoverlifetime speed rotation rotationbyspeed external forces
Vscode automatically generates ifndef define ENDIF of header file
Agent white paper - jointly build agents and create the wisdom of the whole scene | cloud library No.21 recommendation
About queryinterface functions
SDN system method | 9 Access network
篇7:CLion中没有代码提示,,,
Centos7 installing redis 7.0.2
[matlab] curve fitting
力扣每日一题-第27天-561.数组拆分Ⅰ
观察者模式之通用消息发布与订阅