首页 > 其他分享 >systick 理解

systick 理解

时间:2023-03-03 19:00:46浏览次数:30  
标签:function instruction stack PC 理解 systick 堆栈 ARM

 

systick 中断的优先级往往设置为最低值,而不是最高值;如果设置为最低值不会发生上图标号[6]处的情况,设置为最低可能会被其他中断抢占,延长systick的响应时间,但是这个延迟不会累计,因为systick的周期是固定的。举个例子,比如tick是1s一次,假设中断被抢占后会延迟tick中断响应100ms,那么心跳的时钟节拍由1s 2s 3s 4s 5s 6s 变成了1s <抢占> 2.1s 3.1s 4.1s 5.1s 6.1s,之后再抢占一次就变成了 1s 2.1s <抢占> 3.2s 4.2s 5.2s 6.2s,之后再抢占一次就变成了 1s 2.1s 3.2s <抢占> 4.3s 5.3s 6.3s,心跳间隔永远是均匀的1s。

 

大小端:

 

 

寄存器:

R0-R12: can be used during common operations to store temporary values, pointers (locations to memory), etc. R0, for example, can be referred as accumulator during the arithmetic operations or for storing the result of a previously called function. R7 becomes useful while working with syscalls as it stores the syscall number and R11 helps us to keep track of boundaries on the stack serving as the frame pointer (will be covered later). Moreover, the function calling convention on ARM specifies that the first four arguments of a function are stored in the registers r0-r3.

R0-R12:可以在常见操作中用于存储临时值、指针(内存位置)等。例如,R0可以在算术运算期间作为累加器引用,也可以用于存储先前调用的函数的结果。R7在处理系统调用时非常有用,因为它存储系统调用号,R11帮助我们跟踪堆栈上的边界,作为帧指针(稍后将介绍)。此外,ARM上的函数调用约定指定函数的前四个参数存储在寄存器r0-r3中。

 

R13: SP (Stack Pointer). The Stack Pointer points to the top of the stack. The stack is an area of memory used for function-specific storage, which is reclaimed when the function returns. The stack pointer is therefore used for allocating space on the stack, by subtracting the value (in bytes) we want to allocate from the stack pointer. In other words, if we want to allocate a 32 bit value, we subtract 4 from the stack pointer.

R13: SP(堆栈指针)。堆栈指针指向堆栈的顶部。堆栈是用于特定于函数的存储的内存区域,该区域在函数返回时被回收。因此,堆栈指针用于在堆栈上分配空间,方法是从堆栈指针中减去我们想要分配的值(以字节为单位)。换句话说,如果我们想分配一个32位的值,我们从堆栈指针中减去4。

 

R14: LR (Link Register). When a function call is made, the Link Register gets updated with a memory address referencing the next instruction where the function was initiated from. Doing this allows the program return to the “parent” function that initiated the “child” function call after the “child” function is finished.

R14: LR(链路寄存器)。当函数调用时,链接寄存器会更新一个内存地址,该内存地址引用的是函数发起的下一条指令。这样做允许程序在“子”函数完成后返回到发起“子”函数调用的“父”函数。

 

R15: PC (Program Counter). The Program Counter is automatically incremented by the size of the instruction executed. This size is always 4 bytes in ARM state and 2 bytes in THUMB mode. When a branch instruction is being executed, the PC holds the destination address. During execution, PC stores the address of the current instruction plus 8 (two ARM instructions) in ARM state, and the current instruction plus 4 (two Thumb instructions) in Thumb(v1) state. This is different from x86 where PC always points to the next instruction to be executed.

R15: PC(程序计数器)。程序计数器会根据执行指令的大小自动递增。这个大小在ARM状态下总是4个字节,在THUMB模式下总是2个字节。当分支指令正在执行时,PC保存着目的地址。在执行过程中,PC在ARM状态下存储当前指令加8(两条ARM指令,因为流水线,预取址)的地址,在Thumb(v1)状态下存储当前指令加4(两条Thumb指令)的地址。这与x86不同,在x86中PC总是指向下一条要执行的指令。

 

标签:function,instruction,stack,PC,理解,systick,堆栈,ARM
From: https://www.cnblogs.com/lance9527/p/17176513.html

相关文章

  • 从Linq的Where方法理解泛型、委托应用场景
      最近遇到了一个问题,Linq的Where里面传递的是什么?Where的功能是什么实现的?没有第一时间答上来,在整理相关资料后决定自行实现Linq的Where方法来加深印象。什么是泛型......
  • 可视化大屏|如何理解“科技感”设计?
    在做大屏项目时不难发现,“甲方爸爸”通常更喜欢“科技感”的设计,那在可视化大屏的制作过程中,什么样的设计才能称得上是科技感十足,并且兼顾酷炫的呢?本篇文章将从以下3个方面......
  • 关于Javascript——Promise的一些理解
    Promise是一个构造函数,promise是通过Promise构造函数声明的对象。 promise对象用来“管理”一次异步任务。 通过newPromise()声明一个promise对象的时候需要传两个参......
  • 深入理解webpack的chunkId对线上缓存的思考(转载)
    转载自 https://juejin.cn/post/6844903924818771981#heading-6 作者:Kimm想必经常使用基于webpack打包工具的框架的同学们,无论是使用React还是Vue在性能优化上使用最......
  • JavaScript模块化理解-CommonJS、AMD、CMD、UMD、ES6
    参考:JavaScript模块化-CommonJS、AMD、CMD、UMD、ES6前端模块化——彻底搞懂AMD、CMD、ESM和CommonJS 在JS早期,使用script标签引入JS,会造成以下问题:加载的时候阻塞......
  • 什么是云数据库?小白快速理解
    云原生数据库:是指通过云平台进行构建、部署、交付和自动运维的数据库服务。该服务通过是已DBass(Databaseasaservice)的形态,将数据库架构和实现细节隐藏起来,采用多租户和......
  • php之Opcache深入理解
    PHP项目中,尤其是在高并发大流量的场景中,如何提升PHP的响应时间,是一项十分重要的工作。而Opcache又是优化PHP性能不可缺失的组件,尤其是应用了PHP框架的项目中,作用更是明显。......
  • 学习操作系统P4 理解并发程序执行 (Peterson算法、模型检验与软件自动化工具)
    啊 多一个线程,在状态机里也可以理解为多一个栈帧啊啊啊错误如下图所示啊啊  当只有一个人想上厕所时,只有一个旗子被举起来,因此举旗的人可以直接进厕所......
  • 观于 可用性 的理解
    今天课上,读了《大型网站技术架构:核心原理与案例分析》的关于可用性的章节。什么是可用性?官方解释是说在某段时间,系统是否能够正常运行。正常运行的时间越长,可用性越强......
  • 安全高效 | AIRIOT智慧工地管理解决方案
    建筑工地施工材料、机械设备、工程车、人员各个环节管理相对复杂、建筑业也是安全事故频发的高危行业,安全管控尤为重要。建筑施工单位想要保障安全生产,做好能源消耗管控降低......